【发布时间】:2012-02-18 02:21:54
【问题描述】:
我的客户代码:
public static void inputFiles()
{
File inputFile = new File("colors2.txt");
if (!inputFile.exists()) {
throw new FileNotFoundException(("File not found"));
}
ColorSet colorSetter = new ColorSet(inputFile);
}
我的供应商类构造函数:
public ColorSet(File source) throws FileNotFoundException
{
if (!source.exists()) {
throw new FileNotFoundException(("File not found"));
}
colorInput = source;
}
我不断得到 “未报告的异常 java.io FileNotFoundException;必须被捕获或声明为抛出”
我尝试在客户端方法中捕获它,但它告诉我它不能在正文块中调用,也许我做错了?
【问题讨论】:
标签: java