我在 while 循环中写入文本文件:
BufferedWriter writer = new BufferedWriter("...");
BufferedReader reader = new BufferedReader("...");
while((line = reader.readline()) != null){
....
writer.write(line + "\n");
}
reader.close();
writer.close();
此代码不会在处理每一行后立即将行写入文件。我希望在每次迭代中将该行写入文件。如何做到这一点?
慕哥6287543
相关分类