java追加文本到文件末尾
2024-10-20 06:42:32
public class Test { public static void main(String[] args) { method1("F:\\test.txt" , "测试测试将字符写入文件默默");
} /**
* 追加文件:使用FileOutputStream,在构造FileOutputStream时,把第二个参数设为true
*
* @param fileName
* @param content
*/
public static void method1(String file, String conent) {
BufferedWriter out = null ;
try {
out = new BufferedWriter( new OutputStreamWriter(
new FileOutputStream(file, true )));
out.write(conent);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
最新文章
- 安装 Dubbo 管理控制台
- nginx的内存管理
- tomcat Manger App
- Ibatis,Spring整合(注解方式注入)
- VS2010的调试参数/Zi /DEBUG
- JAVA中的Formatter
- 《k8s 源码分析》- Custom Controller 之 Informer
- PADS Logic VX.2.3 修改软件界面语言
- hduoj 1002 A + B Problem II
- (转)Spring boot(一):入门篇
- BZOJ3963 WF2011MachineWorks(动态规划+斜率优化+cdq分治)
- JQuery ajax请求返回(parsererror)异常处理
- UDP和TCP的比較
- centos7 修改时区
- NOIP2017 D2T3列队
- C++复习11.函数的高级特性
- [Linux] ubuntu 安装 Wireshark
- laravel支持的日志写入模式和日志严重程度级别:
- Effective Objective-C [上]
- 2017浙江工业大学-校赛决赛 XiaoWei的战斗力