73
Java FilterWriter
Java FilterWriter class is an abstract class which is used to write filtered character streams.
The sub class of the FilterWriter should override some of its methods and it may provide additional methods and fields also.
Fields
Modifier | Type | Field | Description |
---|---|---|---|
protected | Writer | out | The underlying character-output stream. |
Constructors
Modifier | Constructor | Description |
---|---|---|
protected | FilterWriter(Writer out) | It creates InputStream class Object |
Methods
Modifier and Type | Method | Description |
---|---|---|
void | close() | It closes the stream, flushing it first. |
void | flush() | It flushes the stream. |
void | write(char[] cbuf, int off, int len) | It writes a portion of an array of characters. |
void | write(int c) | It writes a single character. |
void | write(String str, int off, int len) | It writes a portion of a string. |
FilterWriter Example
Output:
i love my country
While running the current program if the current working directory does not contain the file, a new file is created and CustomFileWriter will write the text “I LOVE MY COUNTRY” in lowercase to the file.
Next TopicJava FilterReader class