Since your main method is calling your fileRead()
method. And instead of handling exception your fileRead() method has decided to throw the Exception.
So in exception scenario, once its thrown from fileRead()
method it should be caught in your main()
method. However, your main() can further throw this exception.
you need to write as
public static void main(String[] args) throws FileNotFoundException {
....
or if you want to handle the exception, you should write as:
public static void main(String[] args) {
File file = new File("magicSquare.txt");
try{
fileRead(file);
} catch (FileNotFoundException ex) {
//exception handling code
}
}