Home »
Java programming language
Java CharArrayReader markSupported() Method with Example
CharArrayReader Class markSupported() method: Here, we are going to learn about the markSupported() method of CharArrayReader Class with its syntax and example.
Submitted by Preeti Jain, on March 27, 2020
CharArrayReader Class markSupported() method
- markSupported() method is available in java.io package.
- markSupported() method is used to check whether this stream support mark() 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 mark() support.
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() method otherwise it returns false.
Example:
// Java program to demonstrate the example
// of boolean markSupported() method of
// CharArrayReader
import java.io.*;
public class MarkSupportedOfCAR {
public static void main(String[] args) {
CharArrayReader car_stm = null;
char[] c_arr = {
'a',
'b',
'c',
'd'
};
try {
// Instantiates CharArrayReader
car_stm = new CharArrayReader(c_arr);
// By using markSupported() method isto
// check whether this stream support mark()
// or not
boolean status = car_stm.markSupported();
System.out.println("car_stm.markSupported(): " + status);
} catch (Exception ex) {
System.out.print("Stream Not Supported mark()!!!!");
} finally {
// Free all system resources linked
// with the stream after closing
// the stream
if (car_stm != null)
car_stm.close();
}
}
}
Output
car_stm.markSupported(): true