PushbackInputStream markSupported() method in Java with Examples
Last Updated :
05 Jun, 2020
The markSupported() method of PushbackInputStream class in Java is used to verify the supportability of mark() and reset() methods. It always returns false as this class does not support mark() and reset().
Syntax:
public boolean markSupported()
Overrides: This method overrides the markSupported() method of FilterInputStream class.
Parameters: This method does not accept any parameter.
Return value: This method returns false as this class does not support mark() and reset().
Exceptions: This method does not throw any exception.
Below programs illustrate markSupported() method of PushbackInputStream class in IO package:
Program 1:
import java.io.*;
public class GFG {
public static void main(String[] args)
throws IOException
{
byte [] byteArray
= new byte [] { 'G' , 'E' , 'E' ,
'K' , 'S' };
InputStream inputStr
= new ByteArrayInputStream(byteArray);
PushbackInputStream pushbackInputStr
= new PushbackInputStream(inputStr);
boolean b
= pushbackInputStr.markSupported();
System.out.println(b);
}
}
|
Program 2:
import java.io.*;
public class GFG {
public static void main(String[] args)
throws IOException
{
byte [] byteArray
= new byte [] { 'H' , 'E' , 'L' ,
'L' , 'O' };
InputStream inputStr
= new ByteArrayInputStream(byteArray);
PushbackInputStream pushbackInputStr
= new PushbackInputStream(inputStr);
boolean b
= pushbackInputStr.markSupported();
System.out.println(b);
}
}
|
References:
https://docs.oracle.com/javase/10/docs/api/java/io/PushbackInputStream.html#markSupported()
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...