Java BufferedInputStream.skip(long n)

Syntax

BufferedInputStream.skip(long n) has the following syntax.

public long skip(long n)  throws IOException

Example

In the following code shows how to use BufferedInputStream.skip(long n) method.


//from   w  ww .ja  va 2s  . com


import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;

public class Main {
  public static void main(String[] args) throws Exception {

    InputStream is = new FileInputStream("C:/test.txt");

    // input stream is converted to buffered input stream
    BufferedInputStream bis = new BufferedInputStream(is);

    // read until a single byte is available
    while (bis.available() > 0) {
      // skip single byte from the stream
      bis.skip(1);

      // read next available byte and convert to char
      char c = (char) bis.read();
      System.out.print(c);
    }
  }
}