Here you can find the source of writeFile(File f, String text)
public static void writeFile(File f, String text) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void writeFile(File f, String text) throws IOException { FileWriter fileWriter = null; BufferedWriter bufferedWriter = null; try {/*from w ww .j av a 2 s.co m*/ fileWriter = new FileWriter(f); bufferedWriter = new BufferedWriter(fileWriter); bufferedWriter.write(text); } finally { if (bufferedWriter != null) bufferedWriter.close(); if (fileWriter != null) fileWriter.close(); } } }