i am doing basic File Handling in Java. what i want is that once i run my code and .txt file is created in specified location and some Text is writtern there , now next time when i write something it should not OVERWRITE it , but should start ahead of it .. For example first time i wrote “Hello java” , next time when i run program and try to write “Java is good ” file should have something like this “Hello java ” “java is good”,,
Right now i am doing this
BufferedWriter bf = new BufferedWriter( new FileWriter("c:\\test.txt"));
bf.write("Hello Java");
bf.close();// and so on .
now when next time i run and type
BufferedWriter bf = new BufferedWriter( new FileWriter("c:\\test.txt"));
bf.write("Java is good ");
bf.close();// and so on .
it should not overwrite , So pleas guide mt about it . Thanks in advance
Just add a boolean argument with value ‘true’ to the FileWriter constructor.
FileWriter#FileWriter(File, boolean)