Java FilterReader

Java FilterReader is used to perform filtering operation on reader stream. It is an abstract class for reading filtered character streams.

The FilterReader provides default methods that passes all requests to the contained stream. Subclasses of FilterReader should override some of its methods and may also provide additional methods and fields.

Field

ModifierTypeFieldDescription
protectedReaderinThe underlying character-input stream.

Constructors

ModifierConstructorDescription
protectedFilterReader(Reader in)It creates a new filtered reader.

Method

Modifier and TypeMethodDescription
voidclose()It closes the stream and releases any system resources associated with it.
voidmark(int readAheadLimit)It marks the present position in the stream.
booleanmarkSupported()It tells whether this stream supports the mark() operation.
booleanready()It tells whether this stream is ready to be read.
intread()It reads a single character.
intread(char[] cbuf, int off, int len)It reads characters into a portion of an array.
voidreset()It resets the stream.
longskip(long n)It skips characters.

Example

In this example, we are using "javaFile123.txt" file which contains "India is my country" text in it. Here, we are converting whitespace with question mark '?'.

Output:

India?is?my?country

Next TopicHava File Class




Latest Courses