我无法查看导致错误的原因。代码低于和低于我收到的错误消息。谢谢。
import java.util.*;
import java.io.*;
public class IO {
public static void main(String[] args) throws Exception {
File inFile = new File("src/passign6/grades.txt");
File outFile = new File("src/passign6/finalgrades.txt");
try (
Scanner input = new Scanner(inFile);
PrintWriter output = new PrintWriter(outFile);) {
int[][] grades = new int[42][];
for (int i = 0; input.hasNextLine() && i < grades.length; i++) {
String line = input.nextLine();
Scanner input2 = new Scanner(line);
for (int j = 0; input2.hasNextInt() && j < grades[i].length; j++) {
grades[i][j] = input.nextInt();
}
input.close();
output.close();
}
}
}
}
Exception in thread "main" java.lang.NullPointerException
at io.IO.main(IO.java:20)