Question

Locked

Java: append using PrintWriter

By vanwykerna ·
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.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Java: append using PrintWriter

by jkeatley In reply to Java: append using Print ...

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.

Back to Software Forum
2 total posts (Page 1 of 1)  

Software Forums