import java.io.*;
public class FileReadTest
{
public static void main(String[] args)
{
?? FileReadTest t = new FileReadTest();
?? t.readMyFile();
}
void readMyFile()
{
?? String temp = null;
?? int count = 0;
?? try
?? {
??? FileReader fr = new FileReader("mydata.txt");
??? BufferedReader br = new BufferedReader(fr);
??? temp = new String();
??? while((temp = br.readLine()) != null)
??? {
???? count++;
???? System.out.println(count + ":" + temp);
??? }
??? br.close();
??? fr.close();
?? }
?? catch(IOException e)
?? {
??? System.out.println("OH,got an IOException error!");
??? e.printStackTrace();
?? }
}
}
posted on 2007-05-28 00:32
jadmin 閱讀(47)
評論(0) 編輯 收藏