Danzel Zuo
2017-11-29 13:11
采纳率: 100%
浏览 2.6k
已采纳

bufferedWriter.write写入时候,忽略换行符,如何解决?

String line;
line = bufferedReader.readLine();
while (line!=null){
line=bufferedReader.readLine();
finalData += line;
finalData += "\n";
// System.out.println("循环内" +finalData);
count++;
}

            bufferedReader.close();

// System.out.println("---------------");
// System.out.println("循环外"+finalData);
// System.out.println(count);
OutputStreamWriter writer = new OutputStreamWriter(fos,"gbk");
BufferedWriter bufferedWriter = new BufferedWriter(writer);
bufferedWriter.write(finalData);
bufferedWriter.newLine();
bufferedWriter.flush();
bufferedWriter.close();


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题