Questions

Java: append using PrintWriter

+
0 Votes
Locked

Java: append using PrintWriter

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.
  • +
    0 Votes
    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.

  • +
    0 Votes
    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.