开发者

Create a file based on conditions

开发者 https://www.devze.com 2023-03-10 15:14 出处:网络
How to write a program in Java t开发者_JAVA技巧o check the existence of a txt file if does not exist than create a new one else append the new txt in that file.FileWriter fstream = new FileWriter(\"fo

How to write a program in Java t开发者_JAVA技巧o check the existence of a txt file if does not exist than create a new one else append the new txt in that file.


FileWriter fstream = new FileWriter("foo.txt",true);
BufferedWriter out = new BufferedWriter(fstream);
out.write("foo bar");
out.close();

The second argumnet to FileWriter tells it to append.

0

精彩评论

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