Class SegmentedInputStream

java.lang.Object
java.io.InputStream
it.unimi.dsi.fastutil.io.MeasurableInputStream
it.unimi.dsi.io.SegmentedInputStream
All Implemented Interfaces:
it.unimi.dsi.fastutil.io.MeasurableStream, Closeable, AutoCloseable

public class SegmentedInputStream extends it.unimi.dsi.fastutil.io.MeasurableInputStream
Exhibits a single InputStream as a number of streams divided into reset()-separated segments.

An instance of this class wraps a given input stream (usually a replicable one, such as a FileInputStream) and exposes its contents as a number of separated input streams. Each such stream, called a block, is defined by a start and a stop position (gaps between blocks are possible). Inside each block we can have one or more segments: each segment is again a separate input stream, but calling reset() moves from one segment to the following one, whereas calling close() moves from a block to the following one.

An instance of this class is enriched with blocks by calling addBlock(long[]). This can also be done on-the-fly, while the underlying input stream is being scanned.

Author:
Alessio Orlandi, Luca Natali, Sebastiano Vigna