Class FastBufferedOutputStream

All Implemented Interfaces:
MeasurableStream, RepositionableStream, Closeable, Flushable, AutoCloseable

public class FastBufferedOutputStream extends MeasurableOutputStream implements RepositionableStream
Lightweight, unsynchronized output stream buffering class with measurability and repositionability.

This class provides buffering for output streams, but it does so with purposes and an internal logic that are radically different from the ones adopted in BufferedOutputStream. The main features follow.

  • All methods are unsychronized.

  • As an additional feature, this class implements the RepositionableStream and MeasurableStream interfaces. An instance of this class will try to cast the underlying byte stream to a RepositionableStream and to fetch by reflection the FileChannel underlying the given output stream, in this order. If either reference can be successfully fetched, you can use position(long) to reposition the stream. Much in the same way, an instance of this class will try to cast the the underlying byte stream to a MeasurableStream, and if this operation is successful, or if a FileChannel can be detected, then position() and length() will work as expected.

Since:
4.4