Thursday, June 11, 2026
HomeLanguagesJavaBufferedReader markSupported() method in Java with Examples

BufferedReader markSupported() method in Java with Examples

The markSupported() method of BufferedReader class in Java is used to verify whether the stream supports the mark() method or not. It returns the boolean value true if the stream supports mark() otherwise it returns false.

Syntax:

public boolean markSupported() 

Overrides: It overrides the markSupported() method of the Reader class.

Parameters: This method does not accept any parameter.

Return value: This method returns a boolean value indicating the supportability of the mark() method by the stream.

Exceptions: This method does not throw any exception.

Below programs illustrate markSupported() method in BufferedReader class in IO package:

Program 1: Assume the existence of the file “c:/demo.txt”.




// Java program to illustrate
// BufferedReader markSupported() method
  
import java.io.*;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // Read the stream 'demo.txt'
        // for containing text "GEEKS"
        FileReader fileReader
            = new FileReader(
                "c:/demo.txt");
  
        // Convert fileReader to
        // bufferedReader
        BufferedReader buffReader
            = new BufferedReader(
                fileReader);
  
        // Returns true if stream
        // supports mark()
        boolean bool
            = buffReader.markSupported();
  
        System.out.println(
            "Support for mark() : "
            + bool);
    }
}


Output:

Supports for mark() : true

Program 2: Assume the existence of the file “c:/demo.txt”.




// Java program to illustrate
// BufferedReader markSupported() method
  
import java.io.*;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // Read the stream 'demo.txt'
        // for containing text "GEEKS"
        FileReader fileReader
            = new FileReader(
                "c:/demo.txt");
  
        // Convert fileReader to
        // bufferedReader
        BufferedReader buffReader
            = new BufferedReader(
                fileReader);
  
        // Returns true if stream
        // supports mark()
        boolean bool
            = buffReader.markSupported();
  
        System.out.println(
            "Support for mark() : "
            + bool);
    }
}


Output:

Supports for mark() : false

References:
https://docs.oracle.com/javase/10/docs/api/java/io/BufferedReader.html#markSupported()

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS