package cn.zxg.Exception;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* try_catch_finally捕获异常
*/
public class Test02 {
public static void main(String[] args) {
//一个try可以包含多个catch
FileReader reader=null;
try {
reader= new FileReader("D:\\a.txt");
char c1=(char)reader.read();
System.out.println(c1);
} catch (FileNotFoundException e) {//子类异常在父类异常前面
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}