class="java">package cn.javass.hello.servletimpl.vo; import java.io.*; public class TestFinally { public static void main(String[] args) { FileInputStream fs=null; try{ fs=new FileInputStream("a.txt"); }catch(IOException e){ System.out.println(e.getLocalizedMessage()); System.out.println(e.getMessage()); System.out.println(e.toString()); e.printStackTrace(); return ; //System.exit(1); }finally{ if(fs!=null){ try{ fs.close(); }catch(Exception e){ e.printStackTrace(); } } System.out.println("程序始终要执行finally里的代码!"); } System.out.println("Hello World!"); } }