code: public static void writeToFile(File file, String content, Charset charset) throws IOException {
          FileOutputStream fos = null;
          OutputStreamWriter writer = null;
          try {
              if (file == null) {
                  throw new FileNotFoundException("No file specified.");
              } else if (!file.exists() && !file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
                  throw new FileNotFoundException("Could not find or create file:" + file.getName());
              }
              fos = new FileOutputStream(file);
              writer = new OutputStreamWriter(fos, charset);
              writer.write(content, 0, content.length());
              writer.flush();
          } finally {
              Closeables.closeQuitely(fos);
              Closeables.closeQuitely(writer);
          }
      }
docs: Writes {@link String} content to {@link File}.
  
  @param file
  @param content
  @param charset
  @throws IOException