import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Demo1 {
public static void main(String[] args) throws IOException {
MyReader reader = new MyReader(new FileReader("src/Demo1.java"));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
}
class MyReader {
private int count;
private BufferedReader bufferedReader;
public MyReader(FileReader reader) {
bufferedReader = new BufferedReader(reader);
}
public String readLine() throws IOException {
String resultString = bufferedReader.readLine();
if (resultString != null)
return ++count + ": " + resultString;
return null;
}
} |