printwriter java append to file

Solutions on MaxInterview for printwriter java append to file by the best coders in the world

showing results for - "printwriter java append to file"
Lucia
06 Jan 2021
1public static void usingPrintWriter() throws IOException 
2{
3    String textToAppend = "Happy Learning !!";
4     
5    FileWriter fileWriter = new FileWriter("c:/temp/samplefile.txt", true); //Set true for append mode
6    PrintWriter printWriter = new PrintWriter(fileWriter);
7    printWriter.println(textToAppend);  //New line
8    printWriter.close();
9}
10