Home »
Java programming language
Java BufferedReader markSupported() Method with Example
BufferedReader Class markSupported() method: Here, we are going to learn about the markSupported() method of BufferedReader Class with its syntax and example.
Submitted by Preeti Jain, on March 01, 2020
BufferedReader Class markSupported() method
- markSupported() method is available in java.io package.
- markSupported() method is used to check whether this BufferedReader supports mark() and reset() method or not.
- markSupported() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
- markSupported() method does not throw an exception at the time of checking supporting methods.
Syntax:
public boolean markSupported();
Parameter(s):
- It does not accept any parameter.
Return value:
The return type of the method is boolean, it returns true when this stream supports mark() and reset() method otherwise it returns false.
Example:
// Java program to demonstrate the example
// of boolean markSupported() method of
// BufferedReader
import java.io.*;
public class MarkSupportedBR {
public static void main(String[] args) throws Exception {
// To open text file by using
// FileInputStream
FileInputStream fis = new FileInputStream("e:/includehelp.txt");
// Instantiates InputStreamReader
InputStreamReader inp_r = new InputStreamReader(fis);
// Instantiates BufferedReader
BufferedReader buff_r = new BufferedReader(inp_r);
// To check whether this stream
// buff_r support mark() , reset()
// or not
boolean status = buff_r.markSupported();
System.out.println("buff_r.markSupported(): " + status);
// To check whether this stream
// inp_r support mark() , reset()
// or not
status = inp_r.markSupported();
System.out.println("inp_r.markSupported(): " + status);
fis.close();
inp_r.close();
buff_r.close();
}
}
Output
buff_r.markSupported(): true
inp_r.markSupported(): false