Class ByteBufferInputStream

All Implemented Interfaces:
MeasurableStream, RepositionableStream, Closeable, AutoCloseable

public class ByteBufferInputStream
extends MeasurableInputStream
implements RepositionableStream
A bridge between byte buffers and input streams.

Java's memory-mapping facilities have the severe limitation of mapping at most Integer.MAX_VALUE bytes, as they expose the content of a file using a MappedByteBuffer. This class can expose a file of arbitrary length as a repositionable MeasurableInputStream that is actually based on an array of MappedByteBuffers, each mapping a chunk of CHUNK_SIZE bytes.

Sebastiano Vigna