import java.io.*;
class BufferedReaderDemo{
public static void main(String[] args){
BufferedReader bufr = null;
try{
FileReader fr = new FileReader("buf.txt");
bufr = new BufferedReader(fr);
String str =null;
while((str= bufr.readLine())!=null){
System.out.println(str);
}
}catch(IOException e){
throw new RuntimeException("file read fail!");
}finally{
try{
if(bufr!=null)
bufr.close();
}catch(IOException e){
throw new RuntimeException("close bufr fail!");
}
}
}
}
中,如果在FileReader fr = new FileReader("buf.txt");时就异常的话,上面的程序是不是有问题? |
|