Home »
Java programming language
Java PushbackInputStream markSupported() Method with Example
PushbackInputStream Class markSupported() method: Here, we are going to learn about the markSupported() method of PushbackInputStream Class with its syntax and example.
Submitted by Preeti Jain, on April 20, 2020
PushbackInputStream Class markSupported() method
- markSupported() method is available in java.io package.
- markSupported() method is used to check whether this stream supports mark(), reset() 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 support mark() method otherwise it returns false.
Example:
// Java program to demonstrate the example
// of boolean markSupported() method of
// PushbackInputStream
import java.io.*;
public class MarkSupportedOfPBIS {
public static void main(String[] args) throws Exception {
byte[] b_arr = {
97,
98,
99,
100
};
InputStream is_stm = null;
PushbackInputStream pb_stm = null;
try {
// Instantiates ByteArrayOutputStream and PushbackInputStream
is_stm = new ByteArrayInputStream(b_arr);
pb_stm = new PushbackInputStream(is_stm);
// By using markSupported() method is to
// check whether this stream supports
// mark() method or not
boolean status = pb_stm.markSupported();
System.out.println("pb_stm.markSupported(): " + status);
} catch (Exception ex) {
System.out.println(ex.toString());
} finally {
if (is_stm != null)
is_stm.close();
if (pb_stm != null)
pb_stm.close();
}
}
}
Output
pb_stm.markSupported(): false