java异常机制-----------throws

package cn.zxg.Exception;

import java.io.FileReader;
import java.io.IOException;

/**
* 使用throws声明异常
*/

public class Test03 {
public static void main(String[] args)throws IOException{
readMyFile();

}

public static void readMyFile() throws IOException {
FileReader reader=null;
reader= new FileReader("D:\\a.txt");
char c1=(char)reader.read();
System.out.println(c1);
if(reader!=null){
reader.close();
}
}
}
posted on 2019-05-23 07:08  zz测试笔记  阅读(302)  评论(0编辑  收藏  举报