@NotThreadSafe public class NonBlockingBufferedWriter extends Writer
BufferedWriter. It is 1:1
rip without the synchronized statements.| Constructor and Description |
|---|
NonBlockingBufferedWriter(Writer aWriter)
Creates a buffered character-output stream that uses a default-sized output
buffer.
|
NonBlockingBufferedWriter(Writer aWriter,
int nBufSize)
Creates a new buffered character-output stream that uses an output buffer
of the given size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush()
Flushes the stream.
|
protected void |
flushBuffer()
Flushes the output buffer to the underlying character stream, without
flushing the stream itself.
|
void |
newLine()
Writes a line separator.
|
void |
write(char[] cbuf,
int nOfs,
int nLen)
Writes a portion of an array of characters.
|
void |
write(int c)
Writes a single character.
|
void |
write(String s,
int off,
int len)
Writes a portion of a String.
|
public NonBlockingBufferedWriter(@Nonnull Writer aWriter)
aWriter - A Writerpublic NonBlockingBufferedWriter(@Nonnull Writer aWriter, @Nonnegative int nBufSize)
aWriter - A WriternBufSize - Output-buffer size, a positive integerIllegalArgumentException - If size is ≤ 0protected void flushBuffer()
throws IOException
IOException - of the writer is not openpublic void write(int c)
throws IOException
write in class WriterIOException - If an I/O error occurspublic void write(char[] cbuf,
int nOfs,
int nLen)
throws IOException
Ordinarily this method stores characters from the given array into this
stream's buffer, flushing the buffer to the underlying stream as needed. If
the requested length is at least as large as the buffer, however, then this
method will flush the buffer and write the characters directly to the
underlying stream. Thus redundant BufferedWriters will not
copy data unnecessarily.
write in class Writercbuf - A character arraynOfs - Offset from which to start reading charactersnLen - Number of characters to writeIOException - If an I/O error occurspublic void write(String s, int off, int len) throws IOException
If the value of the len parameter is negative then no characters
are written. This is contrary to the specification of this method in the
superclass,
which requires that an IndexOutOfBoundsException be thrown.
write in class Writers - String to be writtenoff - Offset from which to start reading characterslen - Number of characters to be writtenIOException - If an I/O error occurspublic void newLine()
throws IOException
IOException - If an I/O error occurspublic void flush()
throws IOException
flush in interface Flushableflush in class WriterIOException - If an I/O error occurspublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionCopyright © 2014–2017 Philip Helger. All rights reserved.