Here you can find the source of writeFile(String str, String filename, boolean append)
public static void writeFile(String str, String filename, boolean append) throws IOException
//package com.java2s; /*************************************************************************** * Copyright (C) 2004, Patrick Charles and Jonas Lehmann * * Distributed under the Mozilla Public License * * http://www.mozilla.org/NPL/MPL-1.1.txt * ***************************************************************************/ import java.io.FileWriter; import java.io.IOException; import java.io.FileOutputStream; public class Main { public static void writeFile(String str, String filename, boolean append) throws IOException { int length = str.length(); FileWriter out = new FileWriter(filename, append); out.write(str, 0, length);/* w ww.j a va 2 s . c o m*/ out.close(); } public static void writeFile(byte[] bytes, String filename, boolean append) throws IOException { FileOutputStream out = new FileOutputStream(filename, append); out.write(bytes, 0, bytes.length); out.close(); } public static void writeFile(byte[][] bytes, String filename, boolean append) throws IOException { writeFile(bytes[0], filename, append); for (int i = 1; i < bytes.length; i++) writeFile(bytes[i], filename, true); } public static void writeFile(byte[][] bytes, int beginIndex, int endIndex, String filename, boolean append) throws IOException { writeFile(bytes[beginIndex], filename, append); for (int i = beginIndex + 1; i <= endIndex; i++) writeFile(bytes[i], filename, true); } }