posts - 495,  comments - 11,  trackbacks - 0

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 阅读(37) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: