Java File Write via ByteBuffer write(SeekableByteChannel channel, long start, byte[] bytes)

Here you can find the source of write(SeekableByteChannel channel, long start, byte[] bytes)

Description

write

License

Open Source License

Declaration

static void write(SeekableByteChannel channel, long start, byte[] bytes) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;

public class Main {
    static void write(SeekableByteChannel channel, long start, byte[] bytes) throws IOException {
        channel.position(start);/* www  .j  av  a2s . c  o  m*/

        ByteBuffer buffer = ByteBuffer.wrap(bytes);
        while (buffer.hasRemaining()) {
            channel.write(buffer);
        }
    }
}

Related

  1. mmap(File file, long offset, long length, boolean writeable)
  2. newWriteableBuffer(int capacity)
  3. write(File file, String content, String encoding)
  4. write(InputStream source, File target)
  5. write(Path file, String content)
  6. write24BitInteger(int integer, ByteOrder order)
  7. writeByte(WritableByteChannel channel, byte value)
  8. writeBytes(Path file, byte[] bytes)
  9. writeComment(File zipFile, String comment)