Class FastByteArrayOutputStream

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

public class FastByteArrayOutputStream extends MeasurableOutputStream implements RepositionableStream, ObjectOutput
Simple, fast byte-array output stream that exposes the backing array.

ByteArrayOutputStream is nice, but to get its content you must generate each time a new object. This doesn't happen here.

This class will automatically enlarge the backing array, doubling its size whenever new space is needed. The reset() method will mark the content as empty, but will not decrease the capacity: use trim() for that purpose.

Author:
Sebastiano Vigna