1.catch块之所以会抛出异常,是因为try块调用的方法本身被声明为会throws Exception,比如:
File f = new File("XXX");
FileInputStream inStream = new FileInputStream(f);
第二行代码之所以要加异常处理,是一位FileInputStream类中的FileInputStream(File file)方法会throws FileNotFoundException ,所以当文件不存在的时候,该方法就会抛出异常。
File f = new File("XXX");
try{
FileInputStream inStream = new FileInputStream(f);
}catch(Exception e){System.out.println(e)}