Question Locked

Java: append using PrintWriter

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I know it's just a small piece of code, but I can for the life of me not remember how you append data to a file and not overwrite previous content.

2 replies

by jkeatley

Take a look at java.io.FileWriter. It has a constructor that takes a String and a boolean, and another that takes a File and a boolean. The boolean flag should be true if you want to append to the file.

Then wrap this instance of FileWriter with a PrintWriter, and you're good to go.

This discussion is closed to new replies.