Here you can find the source of writeFile(String path, String content, Charset charset)
public static Boolean writeFile(String path, String content, Charset charset) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { public static Boolean writeFile(String path) throws IOException { return writeFile(path, null); }//from ww w . jav a2 s . c o m public static Boolean writeFile(String path, String content) throws IOException { return writeFile(path, content, Charset.forName("UTF-8")); } public static Boolean writeFile(String path, String content, Charset charset) throws IOException { Writer writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), charset)); if (content != null) { writer.write(content); } } catch (IOException e) { // TODO return false; } finally { try { writer.close(); } catch (Exception e) { // TODO return false; } } return true; } }