java.lang.Object
java.io.Writer
org.omnifaces.io.ResettableBufferedWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable,ResettableBuffer
This resettable buffered writer will buffer everything until the given buffer size, regardless of flush calls.
Only when the buffer size is exceeded, or when 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().
- Author:
- Bauke Scholtz
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionResettableBufferedWriter(Writer writer, int bufferSize, String characterEncoding) Construct a new resettable buffered writer which wraps the given writer and forcibly buffers everything until the given buffer size in bytes, regardless of flush calls. -
Method Summary
-
Constructor Details
-
ResettableBufferedWriter
Construct a new resettable buffered writer which wraps the given writer and forcibly buffers everything until the given buffer size in bytes, regardless of flush calls. The given character encoding is used to measure the amount of already written bytes in the buffer. regardless of flush calls.- Parameters:
writer- The wrapped writer.bufferSize- The buffer size.characterEncoding- The character encoding.
-
-
Method Details
-
write
- Specified by:
writein classWriter- Throws:
IOException
-
reset
public void reset()Description copied from interface:ResettableBufferPerform a buffer reset.- Specified by:
resetin interfaceResettableBuffer
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
isResettable
public boolean isResettable()Description copied from interface:ResettableBufferReturns true if buffer can be reset.- Specified by:
isResettablein interfaceResettableBuffer- Returns:
trueif buffer can be reset, otherwisefalse.
-