Here you can find the source of writeFile(File f, String content)
public static void writeFile(File f, String content) 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.IOException; import java.io.OutputStreamWriter; public class Main { public static void writeFile(File f, String content) throws Exception { BufferedWriter writer = null; try {/* w w w . j a va 2 s. c o m*/ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), "utf-8")); writer.write(content); } catch (Exception e) { throw e; } finally { if (writer != null) { try { writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } } } } }