1
可能重复:
How to append text to an existing file in Java如何将文本添加到java中的文本文件?
我想将数据添加到一个文本文件中。所以这是一个又一个......所以像:
1
2
3
<add more here>
但我不希望从文件中的文本在所有被删除。这是我使用atm的代码,但它取代了文件中的任何内容。有人可以告诉我怎么做我问的。谢谢。
FileWriter fstream = new FileWriter("thefile.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write("blabla");
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
http://stackoverflow.com/questions/1625234/how-to-append-text-to-an-existing-file-in-java – anon