Class ByteBufferedOutputStream

java.lang.Object
java.io.OutputStream
io.jstach.jstachio.output.ByteBufferedOutputStream
All Implemented Interfaces:
Output<RuntimeException>, BufferedEncodedOutput, ByteBufferEncodedOutput, Output.CloseableEncodedOutput<RuntimeException>, Output.EncodedOutput<RuntimeException>, Closeable, Flushable, AutoCloseable

A custom OutputStream that is designed for generating bytes from pre-encoded output as well as reused carefully either by threadlocals or some other pooling mechanism.

If the buffer is to be reused close() should be called first before it is used or after every time it is used and toBuffer() should be called to get a correct view of the internal buffer.

This is basically the same as Joobys Rockers byte buffer but as an OutputStream because JStachio wants that interface. Consequently this code was heavily inspired from Jooby's custom Rocker Output.

Apache License Version 2.0 https://jooby.io/LICENSE.txt Copyright 2014 Edgar Espina

Author:
agentgt, jknack