Here you can find the source of writeFile(File file, ByteBuffer buffer)
public static void writeFile(File file, ByteBuffer buffer) throws IOException
//package com.java2s; /*// w w w . j av a2 s.com * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; public class Main { public static void writeFile(File file, ByteBuffer buffer) throws IOException { boolean created = file.createNewFile(); assert created : file; try (FileOutputStream fileWriter = new FileOutputStream(file)) { fileWriter.write(buffer.array(), 0, buffer.remaining()); } } }