I keep getting the FileNotFoundException
, even though I´m throwing it.
Here´s the code:
import java.util.*;
import java.io.*;
public class kt_6_2 {
public static void main(String[] args) {
File file = new File("magicSquare.txt");
fileRead(file);
}
static void fileRead (File dummyFile) throws FileNotFoundException {
Scanner scanner = new Scanner(dummyFile);
String[] squareLines = new String[3];
for (int a = 0; a < 3; a++) {
squareLines[a] = scanner.nextLine();
scanner.nextLine();
}
System.out.println(squareLines[2]);
}
}
edit: the error message is:
kt_6_2.java:7: error: unreported exception FileNotFoundException; must be caught
or declared to be thrown
fileRead(file);
^
1 error