// FileReadTest.java // Copyright 1998 DevDaily Interactive, Inc. All Rights Reserved. import java.io.*; class FileReadTest { //--------------------------------------------------< main >--------// public static void main (String[] args) { FileReadTest t = new FileReadTest(); t.readMyFile(); } //--------------------------------------------< readMyFile >--------// void readMyFile() { String record = null; int recCount = 0; try { FileReader fr = new FileReader("mydata.txt"); BufferedReader br = new BufferedReader(fr); record = new String(); while ((record = br.readLine()) != null) { recCount++; System.out.println(recCount + ": " + record); } } catch (IOException e) { // catch possible io errors from readLine() System.out.println("Uh oh, got an IOException error!"); e.printStackTrace(); } } // end of readMyFile() } // end of class