Create a file based on conditions
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.
精彩评论