public void appendTextToFile(File file,String text) throws IOException {
  try (PrintWriter pw=new PrintWriter(new OutputStreamWriter(new FileOutputStream(file,true),StandardCharsets.UTF_8))){
    pw.println(text);
  }
 }

public void appendTextToFile ( File file , String text ) throws IOException { try ( PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( new FileOutputStream ( file , true ) , StandardCharsets . UTF_8 ) ) ) { pw . println ( text ) ; } }
simple helper method to just append a text string to the end of the given filename . the file will be created if it does not exist .
