Java ByteArrayInputStream .skip (long n)
Syntax
ByteArrayInputStream.skip(long n) has the following syntax.
public long skip(long n)
Example
In the following code shows how to use ByteArrayInputStream.skip(long n) method.
/*from www. j ava 2 s.c om*/
import java.io.ByteArrayInputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
byte[] buf = { 65, 66, 67, 68, 69 };
// create new byte array input stream
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
int value = 0;
// read till the end of the stream
while ((value = bais.read()) != -1) {
// skip single byte
bais.skip(1);
System.out.println(value);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »