Java LineNumberReader .setLineNumber (int lineNumber)
Syntax
LineNumberReader.setLineNumber(int lineNumber) has the following syntax.
public void setLineNumber(int lineNumber)
Example
In the following code shows how to use LineNumberReader.setLineNumber(int lineNumber) method.
/* w w w . ja v a 2 s . co m*/
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
public class Main {
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("C:/test.txt");
LineNumberReader lnr = new LineNumberReader(fr);
// set current line number
lnr.setLineNumber(100);
System.out.println("setLineNumber(100) is invoked");
// get current line number
int i = lnr.getLineNumber();
System.out.print("Current line number: " + i);
lnr.close();
}
}
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »