Trying to read a file, and it gives me "java.io.IOException"
807597Feb 19 2005 — edited Feb 19 2005I'm writing a little swing text editor for my first java project, and the open method is like this:
public void openFile() throws IOException {
JFileChooser chooseOpen = new JFileChooser();
chooseOpen.showOpenDialog(null);
File openFile = chooseOpen.getSelectedFile();
FileReader in = new FileReader(openFile);
BufferedReader br = new BufferedReader(in);
String fileText = br.readLine();
output.setText(fileText);
}
It seems like it should work fine to me, you choose a file, and it opens it, then outputs it to my textArea. I even have it throwing IOException. Why is it giving me that message then? (this is the only method I'm having a problem with.)
the full error message is:
unreported exception java.io.IOException; must be caught og declared to be thrown
openFile();
^
1 error
thanks,
alex