PushbackInputStream mark() method in Java with Examples Last Updated : 16 Jun, 2022 Comments Improve Suggest changes Like Article Like Report The mark() method of PushbackInputStream class in Java is used to mark the current position in the input stream. This method does nothing for PushbackInputStream. Syntax: public void mark(int readlimit) Overrides: This method overrides the mark() method of FilterInputStream class. Parameters: This method accepts single parameter readlimit that represents the maximum limit of bytes that can be read before the mark position becomes invalid. Return value: This method does not return any value. Exceptions: This method does not throw any exception. Below programs illustrate mark() method of PushbackInputStream class in IO package: Program 1: Java // Java program to illustrate // PushbackInputStream mark() 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); for (int i = 0; i < byteArray.length; i++) { // Read the character System.out.print( (char)pushbackInputStr.read()); } // Revoke mark() but it does nothing pushbackInputStr.mark(5); } } Output:GEEKS Program 2: Java // Java program to illustrate // PushbackInputStream mark() 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); // Revoke mark() pushbackInputStr.mark(1); for (int i = 0; i < byteArray.length; i++) { // Read the character System.out.print( (char)pushbackInputStr.read()); } } } Output:HELLO References: https://docs.oracle.com/javase/10/docs/api/java/io/PushbackInputStream.html#mark(int) Comment More infoAdvertise with us Next Article PushbackInputStream mark() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-IO package Practice Tags : Java Similar Reads PushbackInputStream markSupported() method in Java with Examples 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() m 2 min read PushbackInputStream read() method in Java with Examples The read() method of PushbackInputStream class in Java is of two types: The read() method of PushbackInputStream class in Java is used to read the next byte of data from the input stream. This method returns the read byte from the input stream in the form of an integer. Syntax: public int read() thr 4 min read PushbackInputStream skip() method in Java with Examples The skip(long n) method of PushbackInputStream class in Java is used to skip over and discards n bytes of data from this input stream. This method first skips over the bytes in the pushback buffer, and then calls the skip method of the main input stream. It returns the actual number of bytes skipped 2 min read PushbackInputStream reset() method in Java with Examples The reset() method of PushbackInputStream class in Java is used to reset the steam to the position where mark() method was called. This method does nothing for PushbackInputStream. Syntax: public void reset() throws IOException Overrides: This method overrides the reset() method of FilterInputStream 2 min read PushbackInputStream close() method in Java with Examples The close() method of PushbackInputStream class in Java is used to closes the input stream and it releases resources of system that are associated with the stream. After calling this method, further calling other method if this class will throw the IOException. Syntax: public void close() throws IOE 2 min read PushbackInputStream unread() method in Java with Examples The unread() method of PushbackInputStream class in Java is of three types: The unread(int b) method of PushbackInputStream class in Java is used to push back a byte by copying it to the front of the pushback buffer. After revoking this method, when the next byte is read it has the value equal to th 6 min read PushbackReader mark(int) method in Java with Examples The mark() method of PushbackReader Class in Java is used to marks the current position of the PushbackReader. In the case of PushbackReader, this method always throws an exception as this method isn't supported by the PushbackReader. Syntax: public void mark(int readAheadLimit) Parameters: This met 2 min read PushbackInputStream available() method in Java with Examples The available() method of PushbackInputStream class in Java is used to find the number of bytes that can be read from the input stream without blocking. It returns the estimated value of this number of bytes. It may be blocked by the next invocation of a method for the same input stream. Syntax: pub 2 min read PushbackReader markSupported() method in Java with Examples The markSupported() method of PushbackReader Class in Java is used to check whether this PushbackReader is supports mark() operation or not. It returns a boolean which states if the reader is mark supported. Syntax: public boolean markSupported() Parameters: This method does not accepts any paramete 2 min read ObjectInputStream read() method in Java with examples The read() method of the ObjectInputStream class in Java reads a byte of data. This method wont run if there is no data. Syntax: public int read() Parameters: This method does not accept any parameter. Return Value: This method returns the byte read, or -1 if the end of the stream is reached. Except 1 min read Like