运用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();
}
}
}