Java: 2-dimensional char Array : <p>i've been trying to programm a game called Sokoban the last few days. The levels of the game are simple .txt files you can swap. I've already read the .txt file by using BufferedReader but have problems with saving it to an 2-dimensional char array because the number of rows and columns are different each level. Someone told me to make use of charAt but how do i do that.</p>

<p>Sokobanlevel format (<a href="http://www.sokoban-online.de/help/sokoban/level-format.html" rel="nofollow noreferrer">http://www.sokoban-online.de/help/sokoban/level-format.html</a>)</p>

<p>Hope you can help me. Thanks.</p>

<pre><code>String file = "...";
BufferedReader br = Files.newBufferedReader();
String line = null;
int rows = file.length;
int cols = file[0].length;
char[][] room = new char [rows][cols];          
while ((line = br.readLine()) != null) {
            System.out.println(room[rows][cols]);
        }
</code></pre>
