How to use BufferedInputStream: skip() method in java code?

DeeKay September 21, 2011 at 8:46 pm · java.io

Below code shows how to use BufferedInputStream: skip() method in java –

/**********************************************************************************
 * Created on Nov, 2004 Copyright(c) http://kodehelp.com All Rights Reserved.
 **********************************************************************************/
package com.kodehelp.java.io;
 
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
 
/**
 * @author http://kodehelp.com
 *
 */
public class BufferedInputStreamSkip {
 
    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream(new File("/test.txt"));
        BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
        while (bufferedInputStream.available() > 0) {
          System.out.println((char) bufferedInputStream.read());
          bufferedInputStream.skip(2);
        }
        bufferedInputStream.close();
 
    }
 
}