Here you can find the source of writeStringToFile(File file, String data, String encoding)
public static void writeStringToFile(File file, String data, String encoding) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class Main { public static void writeStringToFile(File file, String data, String encoding) throws IOException { OutputStream os = null;// ww w . jav a 2 s . c om try { os = new FileOutputStream(file); os.write(data.getBytes(encoding)); } finally { if (null != os) { os.close(); } } } }