Here you can find the source of writeFile(ByteBuffer data, File destination)
public static File writeFile(ByteBuffer data, File destination) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.StandardOpenOption; public class Main { public static File writeFile(ByteBuffer data, File destination) throws IOException { try (FileChannel channel = FileChannel.open(destination.toPath(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) { channel.write(data);//w w w. j a va 2s . co m } return destination; } }