code: public static void write(CharSequence content, File file, String encoding) {
          OutputStream os = null;
          try {
              os = new FileOutputStream(file);
              PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(os, encoding));
              printWriter.print(content);
              printWriter.flush();
              os.flush();
          } catch (IOException e) {
              throw E.unexpected(e);
          } finally {
              close(os);
          }
      }
docs: Write String content to a file with encoding specified
  
  @param content
  The content to write
  @param file
  The file to write
  @param encoding
  encoding used to write the content to file