75.Java异常处理机制throws

 1 package testDate;
 2 import java.io.FileNotFoundException;
 3 import java.io.FileReader;
 4 import java.io.IOException;
 5 public class TestReadFile {
 6     public static void main(String[] args) {
 7         String str = null;
 8         try {
 9             str = new TestReadFile().openFile();
10         } catch (IOException e){
11             e.printStackTrace();
12         }
13         System.out.println(str);
14     }
15     String openFile() throws FileNotFoundException,IOException{
16         FileReader reader = new FileReader("d:/a.txt");
17         char c= (char) reader.read();
18         System.out.println(c);
19         return "";
20     }
21 }

 

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