我正在阅读一个代表迷宫图案的文本文件。每一行都被读入一维字符数组,然后将一个一维数组插入到二维字符数组中。
在下面的方法中得到一个空指针异常
line = (input.readLine()).toCharArray();
private void fillArrayFromFile() throws IOException
{
BufferedReader input = new BufferedReader(new FileReader("maze.txt"));
//Read the first two lines of the text file and determine the x and y length of the 2d array
mazeArray = new char[Integer.parseInt(input.readLine())][Integer.parseInt(input.readLine())];
char [] line = new char[10];
//Add each line of input to mazeArray
for (int x = 0; x < mazeArray[0].length; x++)
{
line = (input.readLine()).toCharArray();
System.out.print(x + " : ");
System.out.println(line);
mazeArray[x] = line;
}
}