Here you can find the source of writeFile(File f, String content, String encoding)
public static void writeFile(File f, String content, String encoding) throws IOException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.zip.GZIPOutputStream; public class Main { private static final String DEFAULT_ENCODING = "UTF-8"; public static void writeFile(File f, String content, String encoding) throws IOException { OutputStreamWriter out = null; try {// www . j av a 2 s . c om if (f.getName().endsWith(".gz")) out = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(f, false)), encoding); else out = new OutputStreamWriter(new FileOutputStream(f, false), encoding); out.append(content); } finally { if (out != null) { try { out.close(); } catch (IOException err) { } } } } public static void writeFile(File f, String content) throws IOException { writeFile(f, content, DEFAULT_ENCODING); } }