I know how to create a PrintWriter and am able to take strings from my gui and print it to a text file.
I want to be able to take the same program and print to the file adding text to the file instead of replacing everything already in the text file. How would I make it so that when more data is added to the text file, it is printed on a new line every time?
Any examples or resources would be awesome.
The second parameter to the
FileWriterconstructor will tell it to append to the file (as opposed to clearing the file).Using a
BufferedWriteris recommended for an expensive writer (i.e. aFileWriter), and using aPrintWritergives you access to println syntax that you’re probably used to from System.out.But the
BufferedWriterandPrintWriterwrappers are not strictly necessary.