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.
| Modifier and Type | Field and Description |
|---|---|
| private int | threshold
The threshold at which the event will be triggered. |
| private boolean | thresholdExceeded
Whether or not the configured threshold has been exceeded. |
| private long | written
The number of bytes written to the output stream. |
| Access | Constructor and Description |
|---|---|
| public | ThresholdingOutputStream(int
The number of bytes at which to trigger an event. threshold)Constructs an instance of this class which will trigger an event at the specified threshold. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | checkThreshold(int
The number of bytes about to be written to the underlying
output stream. count)Checks to see if writing the specified number of bytes would cause the configured threshold to be exceeded. |
| public void | close()
Overrides java. Implements java. |
| public void | flush()
Overrides java. Implements java. |
| public long | Returns: The number of bytes written.Returns the number of bytes that have been written to this output stream. |
| protected abstract OutputStream | Returns: The underlying output stream.Returns the underlying output stream, to which the corresponding
|
| public int | Returns: The threshold point, in bytes.Returns the threshold, in bytes, at which an event will be triggered. |
| public boolean | Returns: true if the threshold has been reached;
false otherwise.Determines whether or not the configured threshold has been exceeded for this output stream. |
| protected abstract void | thresholdReached()
Indicates that the configured threshold has been reached, and that a subclass should take whatever action necessary on this event. |
| public void | write(int
The byte to be written. b)Implements abstract java. |
| public void | write(byte[]
The array of bytes to be written. b)Overrides java. b.length bytes from the specified byte array to this
output stream.
|
| public void | write(byte[]
The byte array from which the data will be written. b, int The start offset in the byte array. off, int The number of bytes to write. len)Overrides java. len bytes from the specified byte array starting at
offset off to this output stream.
|
| threshold | back to summary |
|---|---|
| private int threshold The threshold at which the event will be triggered. | |
| thresholdExceeded | back to summary |
|---|---|
| private boolean thresholdExceeded Whether or not the configured threshold has been exceeded. | |
| written | back to summary |
|---|---|
| private long written The number of bytes written to the output stream. | |
| ThresholdingOutputStream | back to summary |
|---|---|
| public ThresholdingOutputStream(int threshold) Constructs an instance of this class which will trigger an event at the specified threshold.
| |
| checkThreshold | back to summary |
|---|---|
| protected void checkThreshold(int count) throws IOException Checks to see if writing the specified number of bytes would cause the configured threshold to be exceeded. If so, triggers an event to allow a concrete implementation to take action on this.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Closes this output stream and releases any system resources associated with this stream.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Overrides java. Implements java. Flushes this output stream and forces any buffered output bytes to be written out.
| |
| getByteCount | back to summary |
|---|---|
| public long getByteCount() Returns the number of bytes that have been written to this output stream.
| |
| getStream | back to summary |
|---|---|
| protected abstract OutputStream getStream() throws IOException Returns the underlying output stream, to which the corresponding
| |
| getThreshold | back to summary |
|---|---|
| public int getThreshold() Returns the threshold, in bytes, at which an event will be triggered.
| |
| isThresholdExceeded | back to summary |
|---|---|
| public boolean isThresholdExceeded() Determines whether or not the configured threshold has been exceeded for this output stream.
| |
| thresholdReached | back to summary |
|---|---|
| protected abstract void thresholdReached() throws IOException Indicates that the configured threshold has been reached, and that a subclass should take whatever action necessary on this event. This may include changing the underlying output stream.
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements abstract java. Writes the specified byte to this output stream.
| |
| write | back to summary |
|---|---|
| public void write(byte[] b) throws IOException Overrides java. Writes
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Overrides java. Writes
| |