code: public static void saveContentToFile(String content, File file,
                                           String encoding, boolean append) throws IOException {
          BufferedWriter buff = new BufferedWriter(new OutputStreamWriter(
                  new FileOutputStream(file, append), encoding));
          buff.write(content);
          buff.flush();
          buff.close();
      }
docs: 按照指定编码保存相应内容到指定文件
  
  @param content  文件内容
  @param file     文件
  @param encoding 编码
  @param append 是否追加
  @throws IOException io exception