Class BufferingServletOutputStream

java.lang.Object
java.io.OutputStream
javax.servlet.ServletOutputStream
org.nuxeo.ecm.core.io.download.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 Details

    • INITIAL

      public static final int INITIAL
      Initial memory buffer size.
      See Also:
    • MAX

      public static final int MAX
      Maximum memory buffer size, after this a file is used.
      See Also:
    • 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
    • writer

      protected PrintWriter writer
    • memory

      protected ByteArrayOutputStream memory
    • file

      protected OutputStream file
    • tmp

      protected File tmp
  • Constructor Details

    • 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
  • Method Details