Here you can find the source of writeFile(String filename, String text)
public static void writeFile(String filename, String text)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileWriter; import java.io.IOException; public class Main { public static void writeFile(String filename, String text) { try {/*from w ww . j a va2 s .c om*/ // Create file FileWriter fstream = new FileWriter(filename); BufferedWriter out = new BufferedWriter(fstream); out.write(text); // Close the output stream out.close(); } catch (Exception e) {// Catch exception if any System.err.println("Error: " + e.getMessage()); } } public static void close(Closeable closeable) { try { closeable.close(); } catch (IOException ignored) { } } }