Here you can find the source of saveFile(File file, String whatToSave, String encoding)
public static void saveFile(File file, String whatToSave, String encoding)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void saveFile(File file, String whatToSave) { saveFile(file, whatToSave, "UTF8"); }//from ww w .ja v a 2 s.c om public static void saveFile(File file, String whatToSave, String encoding) { if (file.isDirectory()) { throw new IllegalArgumentException("File " + file + " should not be a directory"); } try { BufferedWriter output = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(file), encoding)); output.write(whatToSave); output.close(); } catch (IOException e) { e.printStackTrace(); } } }