Last Updated : 05 Jun, 2020
The
markSupported()method of
BufferedReaderclass in Java is used to verify whether the stream supports the mark() method or not. It returns the boolean value
trueif the stream supports mark() otherwise it returns
false.
Syntax:public boolean markSupported()Overrides:
It overrides the markSupported() method of the
Readerclass.
Parameters:This method does not accept any parameter.
Return value:This method returns a
booleanvalue 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
// 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() : trueProgram 2:
Assume the existence of the file "c:/demo.txt".
Java
// 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() : falseReferences: https://docs.oracle.com/javase/10/docs/api/java/io/BufferedReader.html#markSupported()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4