开发者

how to use append function in file

I want to write in a file but in a way that it should not delete e开发者_Python百科xisting data in that file rather it should append that file. Can anybody please help by giving any example related to appending a file? Thank you


You should use the FileWriter(File file, boolean append) constructor with the boolean value true.

Example

File file = new File("c:/tmp/foo.txt");
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file, true)));
pw.println("Hello, World");
pw.close();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜