Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

PushbackInputStream markSupported() method in Java with Examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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()


My Personal Notes arrow_drop_up
Last Updated : 05 Jun, 2020
Like Article
Save Article
Similar Reads
Related Tutorials