package model;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class FileReadDemo {
public static void main(String[] args){
try {
FileReader fr = new FileReader("E:\\demo.txt");
char[] arr = new char[1024];
int num = 0;
try {
while((num = fr.read(arr))!=-1)
{
System.out.println(new String(arr,0,num));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
原文:http://www.cnblogs.com/xsdf/p/7194106.html