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();
}