FilterReader markSupported() in Java

markSupported(): This method is available in the java.io.FilterReader class of Java.

Syntax:

boolean java.io.FilterReader.markSupported()

This method tells whether this stream supports the mark() operation.

Parameters: NA

Returns: true if and only if this stream supports the mark operation.

Exceptions: NA

Approach

Java

import java.io.FilterReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

public class FilterReadermarkSupported {
    public static void main(String[] args) throws IOException {

        Reader reader = new StringReader("hello");
        FilterReader filterReader = new FilterReader(reader) {
        };

        System.out.println(filterReader.markSupported());
        filterReader.close();
    }
}

Output:

true


Some more methods of FilterReader class.

close(): This method closes the stream and releases any system resources associated with it.

mark(int): This method marks the present position in the stream.

read(): This method reads a single character.

read(char[], int, int): This method reads characters into a portion of an array.

ready(): This method tells whether this stream is ready to be read.

reset(): This method resets the stream.

skip(long): This method skips characters.

No comments:

Post a Comment