java printwriter add to existing file code example
Example: printwriter java append to file
public static void usingPrintWriter() throws IOException
{
String textToAppend = "Happy Learning !!";
FileWriter fileWriter = new FileWriter("c:/temp/samplefile.txt", true); //Set true for append mode
PrintWriter printWriter = new PrintWriter(fileWriter);
printWriter.println(textToAppend); //New line
printWriter.close();
}