code: public static void write(File file, String text, String charset) throws IOException {
          Writer writer = null;
          try {
              FileOutputStream out = new FileOutputStream(file);
              writeUTF16BomIfRequired(charset, out);
              writer = new OutputStreamWriter(out, charset);
              writer.write(text);
              writer.flush();
  
              Writer temp = writer;
              writer = null;
              temp.close();
          } finally {
              closeWithWarning(writer);
          }
      }
docs: Write the text to the File, using the specified encoding.
  
  @param file    a File
  @param text    the text to write to the File
  @param charset the charset used
  @throws IOException if an IOException occurs.
  @since 1.0