Open In App

PushbackInputStream markSupported() method in Java with Examples

Last Updated : 05 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads