【发布时间】:2010-10-26 16:55:23
【问题描述】:
public void populateNotesFromFile()
{
try{
BufferedReader reader = new BufferedReader(new FileReader(DEFAULT_NOTES_SAVED));
String fileNotes = reader.readLine();
while(fileNotes != null){
notes.add(fileNotes);
fileNotes = reader.readLine();
}
reader.close();
}
catch (IOException e){
System.err.println("The desired file " + DEFAULT_NOTES_SAVED + " has problems being read from");
}
catch (FileNotFoundException e){
System.err.println("Unable to open " + DEFAULT_NOTES_SAVED);
}
//make sure we have one note
if (notes.size() == 0){
notes.add("There are no notes stored in your note book");
}
}
每当我编译上述代码时,我都会收到一条消息,说找不到符号类 IOException e
谁能告诉我如何解决它:d
谢谢
【问题讨论】:
-
现在它说在导入所有 io 包后 FileNotFoundException e 已经被捕获
-
FileNotFoundException 需要高于 IOException,因为它是 IOException 的子类。