Here you can find the source of write(ByteBuffer data, String filename, boolean append)
public static void write(ByteBuffer data, String filename, boolean append) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class Main { public static void write(ByteBuffer data, String filename, boolean append) throws IOException { File file = new File(filename); file.getParentFile().mkdirs();//w ww.ja v a2 s . c om write(data, file, append); } public static void write(ByteBuffer data, File file, boolean append) throws IOException { @SuppressWarnings("resource") FileChannel out = new FileOutputStream(file, append).getChannel(); out.write(data); out.close(); } public static void write(CharSequence data, File file, boolean append) throws IOException { BufferedWriter wirter = new BufferedWriter(new FileWriter(file, append)); wirter.write(data.toString()); wirter.flush(); wirter.close(); } }