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