import java.io.*;
public class MyLineNumberReader extends BufferedReader
{
private int line = 0; //行号
public MyLineNumberReader(Reader r)
{
super(r);
}
public void setLineNumber(int lineNumber)
{
this.line = lineNumber;
}
public String myReadLine() throws IOException
{
line++;
return super.readLine();
}
public int getLine()
{
return line;
}
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("buf_copy.txt");
MyLineNumberReader mlnr = new MyLineNumberReader(fr);
String line = null;
mlnr.setLineNumber(2);
while((line = mlnr.myReadLine()) != null)
{
System.out.println(mlnr.getLine() + ":" + line);
}
mlnr.close();
}
}