- All Implemented Interfaces:
- Closeable, Flushable, AutoCloseable
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class ByteSlot
extends OutputStream
Similar to the ByteArrayOutputStream, with the exception that we can prepend an header.
e.g. you write some data and you want to prepend an header that contains the data len or cksum.
ByteSlot slot = new ByteSlot();
// write data
slot.write(...);
slot.write(...);
// write header with the size of the written data
slot.markHead();
slot.write(Bytes.toBytes(slot.size()));
// flush to stream as [header, data]
slot.writeTo(stream);