Here you can find the source of writeFile(String name, String content)
public static void writeFile(String name, String content)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { public static void writeFile(String name, String content) { Writer writer = null;/*from w w w . jav a 2 s .c om*/ try { writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(name), Charset.defaultCharset())); writer.write(content); } catch (IOException ex) { // report } finally { try { writer.close(); } catch (Exception ex) { /*ignore*/} } } }