Here you can find the source of writeStringToFile(File outFile, String s)
public static void writeStringToFile(File outFile, String s) throws IOException
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; public class Main { public static void writeStringToFile(File outFile, String s) throws IOException { OutputStreamWriter writer = null; try {//w w w.ja v a 2s . c o m outFile.getParentFile().mkdirs(); final OutputStream out = new FileOutputStream(outFile); writer = new OutputStreamWriter(out, "UTF-8"); writer.write(s, 0, s.length()); // System.out.println("wrote " + outFile); } finally { try { writer.close(); } catch (final Exception ignored) { } } } }