Java LineNumberReader.skip(long n)
Syntax
LineNumberReader.skip(long n) has the following syntax.
public long skip(long n) throws IOException
Example
In the following code shows how to use LineNumberReader.skip(long n) method.
//from w w w.j ava 2 s . c om
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
public class Main {
public static void main(String[] args) throws IOException {
int i;
// create new reader
FileReader fr = new FileReader("C:/test.txt");
LineNumberReader lnr = new LineNumberReader(fr);
// read till the end of the stream
while ((i = lnr.read()) != -1) {
// skip one byte
lnr.skip(1);
// converts integer to char
char c = (char) i;
// prints char
System.out.print(c);
}
lnr.close();
}
}
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »