Here you can find the source of writeStringToFile(String fileName, String str, boolean isAppend)
public static void writeStringToFile(String fileName, String str, boolean isAppend) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void writeStringToFile(String fileName, String str, boolean isAppend) throws IOException { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, isAppend))); try {//from w w w.j ava2s .co m bw.write(str); bw.flush(); } finally { bw.close(); } } public static void writeStringToFile(String fileName, String str, String encoding, boolean isAppend) throws IOException { BufferedWriter bw = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(fileName, isAppend), encoding)); try { bw.write(str); bw.flush(); } finally { bw.close(); } } }