PushbackInputStream reset() method in Java with Examples Last Updated : 22 Sep, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 class. Parameters: This method does not accept any parameter. Return value: This method does not return any value. Exceptions: This method throws IOException whenever this method is called. Below programs illustrate reset() method of PushbackInputStream class in IO package: Program 1: Java // Java program to illustrate // PushbackInputStream reset() 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 reset() but it does nothing pushbackInputStr.reset(); } } Output: Exception in thread "main" java.io.IOException: mark/reset not supported GEEKS Program 2: Java // Java program to illustrate // PushbackInputStream reset() 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 reset() pushbackInputStr.reset(); for (int i = 0; i < byteArray.length; i++) { // Read the character System.out.print( (char)pushbackInputStr.read()); } } } Output: Exception in thread "main" java.io.IOException: mark/reset not supported References: https://docs.oracle.com/javase/10/docs/api/java/io/PushbackInputStream.html#reset() Comment More infoAdvertise with us Next Article PushbackInputStream skip() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-IO package Practice Tags : Java Similar Reads 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 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 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 mark() method in Java with Examples 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 m 2 min read PushbackReader reset() method in Java with Examples The reset() method of PushbackReader Class in Java is used to reset the Stream. In the case of PushbackReader, this method always throws an exception as this method isn't supported by the PushbackReader. Syntax: public void reset() Parameters: This method do not accepts any parameter. Return Value: 2 min read PushbackReader reset() method in Java with Examples The reset() method of PushbackReader Class in Java is used to reset the Stream. In the case of PushbackReader, this method always throws an exception as this method isn't supported by the PushbackReader. Syntax: public void reset() Parameters: This method do not accepts any parameter. Return Value: 2 min read Like