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!");
}
}
java中异常处理finally代码块的处理
最新推荐文章于 2022-06-28 21:27:44 发布