Почему я получаю здесь исключение NullPointerException

Я читаю текстовый файл, представляющий шаблон лабиринта. каждая строка считывается в массив 1d символов, а затем один массив 1d вставляется в массив 2d символов.

В следующем методе получите исключение nullpointerexception по адресу

        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;
    }
}
0
задан Singh 30 April 2012 в 10:31
поделиться