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

ModifierTypeFieldDescription
protectedWriteroutThe underlying character-output stream.

Constructors

ModifierConstructorDescription
protectedFilterWriter(Writer out)It creates InputStream class Object

Methods

Modifier and TypeMethodDescription
voidclose()It closes the stream, flushing it first.
voidflush()It flushes the stream.
voidwrite(char[] cbuf, int off, int len)It writes a portion of an array of characters.
voidwrite(int c)It writes a single character.
voidwrite(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.






Latest Courses