public abstract class FilterWriter extends Writer
Writer and performs some transformation on the
output data while it is being written. Transformations can be anything from a
simple byte-wise filtering output data to an on-the-fly compression or
decompression of the underlying writer. Writers that wrap another writer and
provide some additional functionality on top of it usually inherit from this
class.FilterReader| Modifier and Type | Field and Description |
|---|---|
protected Writer |
out
The Writer being filtered.
|
| Modifier | Constructor and Description |
|---|---|
protected |
FilterWriter(Writer out)
Constructs a new FilterWriter on the Writer
out. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this writer.
|
void |
flush()
Flushes this writer to ensure all pending data is sent out to the target
writer.
|
void |
write(char[] buffer,
int offset,
int count)
Writes
count characters from the char array buffer
starting at position offset to the target writer. |
void |
write(int oneChar)
Writes the specified character
oneChar to the target writer. |
void |
write(String str,
int offset,
int count)
Writes
count characters from the string str starting at
position index to this writer. |
protected Writer out
protected FilterWriter(Writer out)
out. All writes are
now filtered through this writer.out - the target Writer to filter writes on.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOException - if an error occurs attempting to close this writer.public void flush()
throws IOException
flush in interface Flushableflush in class WriterIOException - if an error occurs attempting to flush this writer.public void write(char[] buffer,
int offset,
int count)
throws IOException
count characters from the char array buffer
starting at position offset to the target writer.write in class Writerbuffer - the buffer to write.offset - the index of the first character in buffer to write.count - the number of characters in buffer to write.IOException - if an error occurs while writing to this writer.public void write(int oneChar)
throws IOException
oneChar to the target writer. Only the
two least significant bytes of the integer oneChar are written.write in class WriteroneChar - the char to write to the target writer.IOException - if an error occurs while writing to this writer.public void write(String str, int offset, int count) throws IOException
count characters from the string str starting at
position index to this writer. This implementation writes
str to the target writer.write in class Writerstr - the string to be written.offset - the index of the first character in str to write.count - the number of chars in str to write.IOException - if an error occurs while writing to this writer.