trouble with JFileChooser
I am working on my assignment, where we have to read data from a file and do some searching and replacing, and write back to the file. We have to get the file object using JFileChooser and I keep getting an error. I wrote a simple little app to test it, and Im getting the same error on the Scanner line:
Code:
unreported exception java.io.FileNotFoundException: must be caught or declared to be thrown
Code:
import java.util.*;
import java.io.*;
import javax.swing.JFileChooser;
public class GeneFinder {
public static void main(String[] args)
{
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showOpenDialog(null)== JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
Scanner input = new Scanner(file);
while(input.hasNext())
{
System.out.println(input.nextLine());
}
input.close();
}
}
}