加载中...

throw处理异常

import java.io.FileReader;
import java.io.IOException;
import java.io.FileNotFoundException;
/**
使用throw处理异常
*/
public class CheckException02 {
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 @ 2021-08-14 10:49  nongeason  阅读(60)  评论(0)    收藏  举报