Code example for MappedByteBuffer

Methods: positionremainingduplicate

     * @return buffer with portion of file content 
     * @throws IOException on any fail of I/O operation 
    public synchronized ByteBuffer readBytes(int length) throws IOException
        int remaining = buffer.remaining() - position;
        if (length > remaining)
            throw new IOException(String.format("mmap segment underflow; remaining is %d but %d requested",
                                                remaining, length));
        ByteBuffer bytes = buffer.duplicate();
        bytes.position(buffer.position() + position).limit(buffer.position() + position + length);
        position += length;
        return bytes;
    public final void readFully(byte[] buffer) throws IOException
Contextual code suggestions in your IDE  Get Codota for Java