运用JAVA读取txt文件(BufferReader)

package com.read;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author dengshaohua
 */
public class ReadPhone {

 /**
  * 读取数据
  */
 public void ReadData(){
  try {
   FileReader read = new FileReader("D:/data.txt");
   BufferedReader br = new BufferedReader(read);
   String row;
   while((row = br.readLine())!=null){
    System.out.println(row);
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e){
   e.printStackTrace();
  }
 }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2008-10-07 18:55  枣阳人在深圳  阅读(14898)  评论(3编辑  收藏  举报