code: public static void writeStringToFile(File file, String data, String charset) throws IOException {
          FileOutputStream fos = openOutputStream(file, false);
          fos.write(data.getBytes(charset));
          fos.close();
      }
docs: Writes a String to a file creating the file if it does not exist.
  
  @param file the file to write
  @param data the content to write to the file
  @param charset the encoding to use, {@code null} means platform default
  @throws IOException in case of an I/O error