Here you can find the source of saveString(String string, File file, String charsetName)
public static void saveString(String string, File file, String charsetName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.File; import java.io.OutputStream; import java.io.FileOutputStream; import java.io.OutputStreamWriter; public class Main { public static void saveString(String string, File file, String charsetName) throws IOException { OutputStream out = new FileOutputStream(file); try {//from w ww. j av a 2s . c o m saveString(string, out, charsetName); } finally { out.close(); } } private static void saveString(String string, OutputStream stream, String charsetName) throws IOException { OutputStreamWriter out; if (charsetName == null) { out = new OutputStreamWriter(stream); } else { out = new OutputStreamWriter(stream, charsetName); } out.write(string, 0, string.length()); out.flush(); } }