public class ResettableBufferedOutputStream extends OutputStream implements ResettableBuffer
close()
is called, then the
buffer will be actually flushed.
There is a reset()
method which enables the developer to reset the buffer, as long as it's not flushed yet,
which can be determined by isResettable()
.
ResettableBufferedWriter
Constructor and Description |
---|
ResettableBufferedOutputStream(int thresholdBufferSize)
Construct a new resettable buffered output stream which forcibly buffers everything until the given threshold
buffer size, regardless of flush calls and calls.
|
ResettableBufferedOutputStream(OutputStream output,
int thresholdBufferSize)
Construct a new resettable buffered output stream which wraps the given output stream and forcibly buffers
everything until the given threshold buffer size, regardless of flush calls.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected OutputStream |
createOutputStream(boolean thresholdBufferSizeExceeded)
Returns the custom implementation of the
OutputStream . |
void |
flush() |
protected int |
getWrittenBytes()
Returns the amount of so far written bytes in the threshold buffer.
|
boolean |
isResettable()
Returns true if buffer can be reset.
|
void |
reset()
Perform a buffer reset.
|
void |
write(byte[] bytes) |
void |
write(byte[] bytes,
int offset,
int length) |
void |
write(int b) |
public ResettableBufferedOutputStream(int thresholdBufferSize)
createOutputStream(boolean)
when
using this constructor.thresholdBufferSize
- The threshold buffer size.public ResettableBufferedOutputStream(OutputStream output, int thresholdBufferSize)
createOutputStream(boolean)
when using this constructor.output
- The wrapped output stream .thresholdBufferSize
- The threshold buffer size.public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] bytes) throws IOException
write
in class OutputStream
IOException
public void write(byte[] bytes, int offset, int length) throws IOException
write
in class OutputStream
IOException
protected OutputStream createOutputStream(boolean thresholdBufferSizeExceeded) throws IOException
OutputStream
. This will only be called when the specified
threshold buffer size is exceeded, or when close()
is called.thresholdBufferSizeExceeded
- Whether the threshold buffer size has exceeded.OutputStream
.IOException
- When an I/O error occurs.protected int getWrittenBytes()
public void reset()
ResettableBuffer
reset
in interface ResettableBuffer
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public boolean isResettable()
ResettableBuffer
isResettable
in interface ResettableBuffer
true
if buffer can be reset, otherwise false
.Copyright © 2012–2021 OmniFaces. All rights reserved.