Class ThresholdingOutputStream

java.lang.Object
java.io.OutputStream
org.apache.tomcat.util.http.fileupload.ThresholdingOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Direct Known Subclasses:
DeferredFileOutputStream

public abstract class ThresholdingOutputStream extends OutputStream
An output stream which triggers an event when a specified number of bytes of data have been written to it. The event can be used, for example, to throw an exception if a maximum has been reached, or to switch the underlying stream type when the threshold is exceeded.

This class overrides all OutputStream methods. However, these overrides ultimately call the corresponding methods in the underlying output stream implementation.

NOTE: This implementation may trigger the event before the threshold is actually reached, since it triggers when a pending write operation would cause the threshold to be exceeded.