????????????????
????public class NeverCaught{
????static void f()throws ExceptionB{
????throw new ExceptionB("exception b");
????}
????static void g()throws ExceptionC{
????try{
????f();
????}catch(ExceptionB e){
????ExceptionC c=new ExceptionC("exception a");
????throw c;
????}
????}
????public static void main(String[]args){
????try{
????g();
????}catch(ExceptionC e){
????e.printStackTrace();
????}
????}
????}
????/*
????exception.ExceptionC
????at exception.NeverCaught.g(NeverCaught.java:12)
????at exception.NeverCaught.main(NeverCaught.java:19)
????*/
??????????????????ExceptionC????д????ExceptionB???????????????????°?!
???????????????????????????????????????????з???????????????????????????????????????????????????????????????????????????????????????????????????
????public class NeverCaught{
????static void f()throws ExceptionB{
????throw new ExceptionB("exception b");
????}
????static void g()throws ExceptionC{
????try{
????f();
????}catch(ExceptionB e){
????ExceptionC c=new ExceptionC("exception a");
????//????
????c.initCause(e);
????throw c;
????}
????}
????public static void main(String[]args){
????try{
????g();
????}catch(ExceptionC e){
????e.printStackTrace();
????}
????}
????}
????/*
????exception.ExceptionC
????at exception.NeverCaught.g(NeverCaught.java:12)
????at exception.NeverCaught.main(NeverCaught.java:21)
????Caused by:exception.ExceptionB
????at exception.NeverCaught.f(NeverCaught.java:5)
????at exception.NeverCaught.g(NeverCaught.java:10)
????...1 more
????*/
???????????????????????????????????????initCause()???????Throwable??е??
??????4.???????
???????????????????????????????????????Щ??????????????????IO??JDBC??????????????????м??????????????????????????ζ?????й??????????????????????????????????????£????????????????????????finally??
????public void readFile(String file){
????BufferedReader reader=null;
????try{
????reader=new BufferedReader(new InputStreamReader(
????new FileInputStream(file)));
????//do some other work
????}catch(FileNotFoundException e){
????e.printStackTrace();
????}finally{
????try{
????reader.close();
????}catch(IOException e){
????e.printStackTrace();
????}
????}
????}