Class ResettableBufferedOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable, ResettableBuffer

    public class ResettableBufferedOutputStream
    extends OutputStream
    implements ResettableBuffer
    This resettable buffered output stream will buffer everything until the given threshold buffer size, regardless of flush calls. Only when the specified threshold buffer size is exceeded, or when close() is called, then the buffer will be actually flushed.

    There is a reset() method which enables the developer to reset the buffer, as long as it's not flushed yet, which can be determined by isResettable().

    Author:
    Bauke Scholtz
    See Also:
    ResettableBufferedWriter
    • Constructor Detail

      • ResettableBufferedOutputStream

        public ResettableBufferedOutputStream​(int thresholdBufferSize)
        Construct a new resettable buffered output stream which forcibly buffers everything until the given threshold buffer size, regardless of flush calls and calls. You need to override createOutputStream(boolean) when using this constructor.
        Parameters:
        thresholdBufferSize - The threshold buffer size.
      • ResettableBufferedOutputStream

        public ResettableBufferedOutputStream​(OutputStream output,
                                              int thresholdBufferSize)
        Construct a new resettable buffered output stream which wraps the given output stream and forcibly buffers everything until the given threshold buffer size, regardless of flush calls. You do not need to override createOutputStream(boolean) when using this constructor.
        Parameters:
        output - The wrapped output stream .
        thresholdBufferSize - The threshold buffer size.