Methods Summary |
---|
protected void | checkThreshold(int count)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.
if (!thresholdExceeded && (written + count > threshold))
{
thresholdReached();
thresholdExceeded = true;
}
|
public void | close()Closes this output stream and releases any system resources associated
with this stream.
try
{
flush();
}
catch (IOException ignored)
{
// ignore
}
getStream().close();
|
public void | flush()Flushes this output stream and forces any buffered output bytes to be
written out.
getStream().flush();
|
public long | getByteCount()Returns the number of bytes that have been written to this output stream.
return written;
|
protected abstract java.io.OutputStream | getStream()Returns the underlying output stream, to which the corresponding
OutputStream methods in this class will ultimately delegate.
|
public int | getThreshold()Returns the threshold, in bytes, at which an event will be triggered.
return threshold;
|
public boolean | isThresholdExceeded()Determines whether or not the configured threshold has been exceeded for
this output stream.
return (written > threshold);
|
protected abstract void | thresholdReached()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.
|
public void | write(int b)Writes the specified byte to this output stream.
checkThreshold(1);
getStream().write(b);
written++;
|
public void | write(byte[] b)Writes b.length bytes from the specified byte array to this
output stream.
checkThreshold(b.length);
getStream().write(b);
written += b.length;
|
public void | write(byte[] b, int off, int len)Writes len bytes from the specified byte array starting at
offset off to this output stream.
checkThreshold(len);
getStream().write(b, off, len);
written += len;
|