Skip to content
Related Articles

Related Articles

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:




// Java program to illustrate
// PushbackInputStream markSupported() method
  
import java.io.*;
  
public class GFG {
    public static void main(String[] args)
        throws IOException
    {
  
        // Create an array
        byte[] byteArray
            = new byte[] { 'G', 'E', 'E',
                           'K', 'S' };
  
        // Create inputStream
        InputStream inputStr
            = new ByteArrayInputStream(byteArray);
  
        // Create object of
        // PushbackInputStream
        PushbackInputStream pushbackInputStr
            = new PushbackInputStream(inputStr);
  
        boolean b
            = pushbackInputStr.markSupported();
  
        System.out.println(b);
    }
}
Output:
false

Program 2:




// Java program to illustrate
// PushbackInputStream markSupported() method
  
import java.io.*;
  
public class GFG {
    public static void main(String[] args)
        throws IOException
    {
  
        // Create an array
        byte[] byteArray
            = new byte[] { 'H', 'E', 'L',
                           'L', 'O' };
  
        // Create inputStream
        InputStream inputStr
            = new ByteArrayInputStream(byteArray);
  
        // Create object of
        // PushbackInputStream
        PushbackInputStream pushbackInputStr
            = new PushbackInputStream(inputStr);
  
        boolean b
            = pushbackInputStr.markSupported();
  
        System.out.println(b);
    }
}
Output:
false

References:
https://docs.oracle.com/javase/10/docs/api/java/io/PushbackInputStream.html#markSupported()

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :