import java.io.FileReader; import java.io.IOException; import java.io.LineNumberReader; public class MainClass { public static void main(String[] argv) { try { FileReader fr = new FileReader("data"); LineNumberReader lnr = new LineNumberReader(fr); String s; while ((s = lnr.readLine()) != null) { System.out.println(lnr.getLineNumber() + " : " + s); } lnr.close(); fr.close(); } catch (IOException x) { } } }