文本操作工具类
来源:互联网 发布:大数据定义和概念 编辑:程序博客网 时间:2024/06/06 01:07
public static void contentToTxt(String filePath, List<String> content) {
String str = new String(); //原有txt内容
String s1 = new String();//内容更新
try {
File f = new File(filePath);
if (f.exists()) {
System.out.print("文件存在");
} else {
System.out.print("文件不存在");
f.createNewFile();// 不存在则创建
}
BufferedReader input = new BufferedReader(new FileReader(f));
while ((str = input.readLine()) != null) {
s1 += str + "\n";
}
System.out.println(s1);
input.close();
for(int i=0;i<content.size();i++) {
System.out.println(content.get(i));
s1 += content.get(i);
}
//s1 += content;
BufferedWriter output = new BufferedWriter(new FileWriter(f));
output.write(s1);
output.close();
} catch (Exception e) {
e.printStackTrace();
}
}
String str = new String(); //原有txt内容
String s1 = new String();//内容更新
try {
File f = new File(filePath);
if (f.exists()) {
System.out.print("文件存在");
} else {
System.out.print("文件不存在");
f.createNewFile();// 不存在则创建
}
BufferedReader input = new BufferedReader(new FileReader(f));
while ((str = input.readLine()) != null) {
s1 += str + "\n";
}
System.out.println(s1);
input.close();
for(int i=0;i<content.size();i++) {
System.out.println(content.get(i));
s1 += content.get(i);
}
//s1 += content;
BufferedWriter output = new BufferedWriter(new FileWriter(f));
output.write(s1);
output.close();
} catch (Exception e) {
e.printStackTrace();
}
}
阅读全文
0 0
- 文本操作工具类
- 文本转换工具类
- JAVA工具类(12)---文本字符串工具类(数据替换,加密解密操作)
- 字符文本操作类
- 文本选区操作类
- PHP文本操作类
- PHP文本操作类
- (4)文本挖掘(一)——准备文本读写及对Map操作的工具类
- 读取text文本工具类
- 文本工具
- 文本工具
- Java 操作文本 封装类
- [文本处理] 文本综合类工具:wfr.exe
- 文本操作
- Android的文本编解码工具类
- 在android中高亮文本工具类
- java处理文本计算词频工具类
- 文件操作工具类
- 支付系统风控系统建设思考
- PHP的四种运行模式
- MFC GDI+实现以鼠标为中心缩放图片(并且可以拖动)
- 用户模式与内核模式(2)
- Android camera onPreviewFrame 图片旋转问题
- 文本操作工具类
- linux下编程实现GPS数据获取与解析(2)
- Oracle SQL之lag()和lead()函数使用
- springboot和mybatis整合(二)
- 页面内锚点定位及跳转方法
- Java Number & Math 类
- ueditor使用
- 一个老鸟发的公司内部整理的 Android 学习路线图
- ArcGIS for Android 离线数据空间查询--I查询