public static void appendToFile(final File file,final String contents) throws IOException {
  try (FileOutputStream fos=new FileOutputStream(file,true)){
    fos.write(contents.getBytes());
  }
 }

public static void appendToFile ( final File file , final String contents ) throws IOException { try ( FileOutputStream fos = new FileOutputStream ( file , true ) ) { fos . write ( contents . getBytes ( ) ) ; } }
appends the contents string to a file .
