How to append text to a file with the Java FileWriter class
By Alvin Alexander. Last updated: September 30 2019
Java file writing FAQ: How do I append text to the end of a text file in Java?
The short answer is that you should create a FileWriter
instance with the append flag set to true, like this:
BufferedWriter bw = new BufferedWriter(new FileWriter("checkbook.dat", true));
The rest of this article explains this.