Java ByteBuffer Write writeFile(File file, ByteBuffer buffer)

Here you can find the source of writeFile(File file, ByteBuffer buffer)

Description

write File

License

Mozilla Public License

Declaration

public static void writeFile(File file, ByteBuffer buffer) throws IOException 

Method Source Code


//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());
        }
    }
}

Related

  1. writeEmpty(final ByteBuffer buffer, final int type)
  2. writeFakeImageData(ByteBuffer out, int lzwMinCodeSize)
  3. writeFFloat(ByteBuffer buffer, float value)
  4. writeFile(ByteBuffer data, File destination)
  5. writeFile(File file, ByteBuffer bb)
  6. writeFileFragment(FileChannel fc, long pos, ByteBuffer fragment)
  7. writeFloat(ByteBuffer buffer, float f)
  8. writeFromBuffer(SocketChannel channel, ByteBuffer buf, int sleepMsecs)
  9. writeFully(@Nonnull final FileChannel dst, @Nonnull final ByteBuffer src, @Nonnegative final long position)