Java FilterReaderJava 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. FieldModifier | Type | Field | Description |
---|
protected | Reader | in | The underlying character-input stream. |
ConstructorsModifier | Constructor | Description |
---|
protected | FilterReader(Reader in) | It creates a new filtered reader. |
MethodModifier and Type | Method | Description |
---|
void | close() | It closes the stream and releases any system resources associated with it. | void | mark(int readAheadLimit) | It marks the present position in the stream. | boolean | markSupported() | It tells whether this stream supports the mark() operation. | boolean | ready() | It tells whether this stream is ready to be read. | int | read() | It reads a single character. | int | read(char[] cbuf, int off, int len) | It reads characters into a portion of an array. | void | reset() | It resets the stream. | long | skip(long n) | It skips characters. |
ExampleIn 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:
|