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.
public long skip(long n) throws IOException
Overrides: This method overrides the skip() method of FilterInputStream class.
Parameters: This method accepts one parameter n which represents the number of bytes to be skipped.
Return value: This method returns the actual number of bytes skipped.
Exceptions: This method throws IOException if the stream has been closed by calling close() method or if an I/O error occurs.
Below programs illustrate skip(long) method of PushbackInputStream class in IO package:
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.