Here you can find the source of writeStringToFile(String contents, File outputFile)
public static void writeStringToFile(String contents, File outputFile)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; public class Main { public static void writeStringToFile(String contents, File outputFile) { Writer os = null;/*from ww w . ja v a2 s . c om*/ try { FileOutputStream fos = new FileOutputStream(outputFile); os = new OutputStreamWriter(fos, "UTF-8"); os.write(contents); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } finally { if (os != null) { try { os.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } } } } }