Here you can find the source of writeFile(File file, String text)
public static void writeFile(File file, String text) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.Writer; public class Main { private static final String ENCODING = "UTF-8"; public static void writeFile(File file, String text) throws Exception { writeFile(file, text, false);/*from www .j a v a 2 s . c o m*/ } public static void writeFile(File file, String text, boolean append) throws Exception { Writer out = null; try { out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), ENCODING)); out.append(text); out.flush(); } catch (Exception e) { throw e; } finally { if (out != null) { out.close(); } } } }