Here you can find the source of writeFile(String path, String text)
private static void writeFile(String path, String text) throws IOException
//package com.java2s; /**//www. java2s . c om @license http://www.apache.org/licenses/LICENSE-2.0 @author Goetz Hatop @title Simple Utility Class to wrap Filesystem access @date 2013-01-18 */ import java.io.IOException; import java.io.Writer; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.FileOutputStream; import java.io.FileNotFoundException; public class Main { private static void writeFile(String path, String text) throws IOException { Writer out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), "UTF-8")); out.write(text); } catch (FileNotFoundException e) { //throw new IOException(e.toString()); } finally { if (out != null) out.close(); } } public static void write(String path, String text) { try { writeFile(path, text); } catch (IOException e) { e.printStackTrace(); } } }