package hanjia;
import java.io.*;
//自动关闭资源的try
public class hanjia{
public static void main(String args[]) {
//自动关闭资源的try是jdk7.0以上才行
try (FileInputStream file=new FileInputStream("f://f.txt")){
}catch(IOException ioe) {
System.out.println("捕获异常:"+ioe.getMessage()); //详细描述当前异常信息
}
//包含了隐式的finally快,file.close()关闭资源
System.out.println("继续执行程序");
}
}
个人理解及资料参考,若有不足或者需要扩展请指点。
若有雷同,纯属巧合。