java 怎么将一个list集合插入到一个文本文件中
1个回答
2017-03-28 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
//输入文件
File inFile = new File("paiming.txt");
FileReader fileReader = new FileReader(inFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
//输出文件
File outFile = new File("aa.txt");
FileWriter fileWriter = new FileWriter(outFile,true);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.newLine();
String str = null;
while((str=bufferedReader.readLine())!=null){
bufferedWriter.write(str);
bufferedWriter.newLine();
bufferedWriter.flush();
}
//关闭输入输出流
bufferedReader.close();fileReader.close();
bufferedWriter.close();fileWriter.close();
//删除原输入文件
inFile.delete();
//输出文件改名
outFile.renameTo(new File("paiming.txt"));
File inFile = new File("paiming.txt");
FileReader fileReader = new FileReader(inFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
//输出文件
File outFile = new File("aa.txt");
FileWriter fileWriter = new FileWriter(outFile,true);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.newLine();
String str = null;
while((str=bufferedReader.readLine())!=null){
bufferedWriter.write(str);
bufferedWriter.newLine();
bufferedWriter.flush();
}
//关闭输入输出流
bufferedReader.close();fileReader.close();
bufferedWriter.close();fileWriter.close();
//删除原输入文件
inFile.delete();
//输出文件改名
outFile.renameTo(new File("paiming.txt"));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询