需要捕获异常try {
FileInputStream fin = new FileInputStream("filename.txt");
}
catch (Exception ex) {
System.out.println("读取文件"+filename+"出错!");
}
FileInputStream fin = new FileInputStream("filename.txt");
}
catch (Exception ex) {
System.out.println("读取文件"+filename+"出错!");
}
catch(Exception e) { //deal with the exception here }这样能够捕捉到所有上边的catch语句未能捕捉到的Exception