我正在使用 aJOptionPane
向用户询问文件,然后将其提供给BufferedReader
. 但是,我的代码不断抛出FileNotFoundException
. 有人可以帮我理解为什么。
这是我的代码...
edit = JOptionPane.showInputDialog("Enter a file to edit");
try {
BufferedReader fIn = new BufferedReader(new FileReader(edit));
String in;
try {
while((in = fIn.readLine()) != null) {
System.out.println(in);
}
fIn.close();
}
catch (IOException ex) {
Logger.getLogger(WordProcessor.class.getName()).log(Level.SEVERE, null, ex);
}
try {
fIn.close();
}
catch (IOException ex) {
Logger.getLogger(WordProcessor.class.getName()).log(Level.SEVERE, null, ex);
}
}
catch (FileNotFoundException ex) {
JOptionPane.showMessageDialog(null, "File does not exist");
}