package cn.itcast_09;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
/*
* BufferedReader
* |--LineNumberReader
* public int getLineNumber():获取当前行号
* public void setLineNumber(int lineNumber):设置当前行号
*/
public class LineNumberReaderDemo {
public static void main(String[] args) throws IOException {
LineNumberReader lnr = new LineNumberReader(new FileReader("my.txt"));
// 从10开始比较好
lnr.setLineNumber(10);
String line = null;
while ((line = lnr.readLine()) != null) {
System.out.println(lnr.getLineNumber() + ":" + line);
}
// 释放资源
lnr.close();
}
}