public char[][] readMaze() { char[][] maze = null; try { Scanner in = new Scanner(new File("maze.txt")); int width = in.nextInt(), height = in.nextInt(); in.nextLine(); maze = new char[height][width]; for (int i = 0; i < height; i++) { int j = 0; String s = in.nextLine(); for (char c : s.toCharArray()) { if (c == 'S') { x = j; y = i; System.out.println("match " + x + " " + y); } maze[i][j++] = c; } } in.close(); } catch (Exception e) { e.printStackTrace(); } return maze; }