Class BufferingServletOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class BufferingServletOutputStream
    extends javax.servlet.ServletOutputStream
    A ServletOutputStream that buffers everything until stopBuffering() is called.

    There may only be one such instance per thread.

    Buffering is done first in memory, then on disk if the size exceeds a limit.

    • Field Detail

      • MAX

        public static final int MAX
        Maximum memory buffer size, after this a file is used.
        See Also:
        Constant Field Values
      • streaming

        protected boolean streaming
        Have we stopped buffering to pass writes directly to the output stream.
      • needsFlush

        protected boolean needsFlush
      • needsClose

        protected boolean needsClose
      • outputStream

        protected final javax.servlet.ServletOutputStream outputStream
      • tmp

        protected File tmp
    • Constructor Detail

      • BufferingServletOutputStream

        public BufferingServletOutputStream​(javax.servlet.ServletOutputStream outputStream)
        A ServletOutputStream wrapper that buffers everything until stopBuffering() is called.

        stopBuffering() MUST be called in a finally statement in order for resources to be closed properly.

        Parameters:
        outputStream - the underlying output stream