PushbackReader markSupported() in Java

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

Syntax:

boolean java.io.PushbackReader.markSupported()

This method tells whether this stream supports the mark() operation, which it does not.

Parameters: NA

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

Exceptions: NA

Approach

Java

import java.io.IOException;
import java.io.PipedReader;
import java.io.PushbackReader;
import java.io.Reader;

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

        Reader in = new PipedReader();
        PushbackReader pushbackReader = new PushbackReader(in);

        System.out.println(pushbackReader.markSupported());

        pushbackReader.close();
    }
}

Output:

false


Some other methods of PushbackReader

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.

markSupported(): This method tells whether this stream supports the mark() operation, which it does not.

PushbackReader(Reader): This method creates a new pushback reader with a one-character pushback buffer.

PushbackReader(Reader, int): This method creates a new pushback reader with a pushback buffer of the given size.

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

unread(char[]): This method pushes back an array of characters by copying it to the front of the pushback buffer.

unread(int): This method pushes back a single character by copying it to the front of the pushback buffer.

unread(char[], int, int):  This method pushes back a portion of an array of characters by copying it to the front of the pushback buffer.

No comments:

Post a Comment