Here you can find the source of writeToFile(File target, String s, String charSet)
public static void writeToFile(File target, String s, String charSet) throws FileNotFoundException, IOException, UnsupportedEncodingException
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; public class Main { public static void writeToFile(File target, String s, String charSet) throws FileNotFoundException, IOException, UnsupportedEncodingException { FileOutputStream fos = new FileOutputStream(target); fos.write(s.getBytes(charSet));/*from ww w.java 2s. c om*/ fos.close(); } }