75.Java异常处理机制-手动抛出异常

 1 package testDate;
 2 import java.io.File;
 3 import java.io.FileNotFoundException;
 4 public class TestReadFile {
 5     public static void main(String[] args) {
 6         File f=new File("d:/b.txt");
 7         if(!f.exists()){
 8             try{
 9                 //手动抛出异常
10                 throw new FileNotFoundException("File can't be found !");
11             }catch(FileNotFoundException e){
12                 e.printStackTrace();
13             }
14         }
15     }
16 }

posted @ 2017-12-08 12:34  wydxry  阅读(1354)  评论(0编辑  收藏  举报
Live2D