return永远先执行finally语句中的 return
package exceptio;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadException {
public static void main(String[] args) {
//2.把reader的声明放在外面
FileReader reader=null;
try{
//1.Reader是try内部的局部变量
reader= new FileReader("E:\\a.txt");
char a= (char)reader.read();
System.out.print(a);
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
try{
if(reader!=null){
reader.close();
}
}catch(IOException e){
e.printStackTrace();
}
}
}
}