Why does this program result in an InputMismatchException?

25 views Asked by At
private static int[] loadMarks(String fileName) throws IOException {

    int[] marks = new int[94];  
    /* complete */
    Scanner input = new Scanner(fileName);
    for(int i=0;i<94;i++) {
        marks[i]=input.nextInt();
    }
    return marks;
}
1

There are 1 answers

0
Tyler On
Scanner input = new Scanner(new File(fileName));

Try this, if your goal is to parse the contents of the file and not the actual string fileName