public static void writeStringToFile(File file,String data,Charset encoding,boolean append) throws IOException {
  OutputStream out=null;
  try {
    out=openOutputStream(file,append);
    IOUtils.write(data,out,encoding);
    out.close();
  }
  finally {
    IOUtils.closeQuietly(out);
  }
}

public static void writeStringToFile ( File file , String data , Charset encoding , boolean append ) throws IOException { OutputStream out = null ; try { out = openOutputStream ( file , append ) ; IOUtils . write ( data , out , encoding ) ; out . close ( ) ; } finally { IOUtils . closeQuietly ( out ) ; } }
writes a string to a file creating the file if it does not exist .
