Get element by element from an unseparated txt file and put into a matrix
<p><a href="https://i.stack.imgur.com/qymjo.png" rel="nofollow noreferrer">How it should look my maze game. </a>Here's my code. My text file contains 0 and 1 unseparated by space. (33 lines, 43 columns). I can't put the elements(character by character) in the matrix and the number of columns returned is equal to the rows number.</p>

<pre><code>private Scanner scanner, colReader;
private int rows = 0;
private int columns = 0;
private int i = 0;
private int j = 0;
private String fileName = "C://Users//blidaru//Desktop//Lab.txt";
private String[][] matrix = null;

public Main() throws FileNotFoundException {

    try {
        scanner = new Scanner(new File(fileName));
    }

    catch (Exception e) {
        System.out.println("Unable to open file");
    }

    while (scanner.hasNextLine()) {

        ++rows;
        ++i;
        colReader = new Scanner(scanner.nextLine());
        scanner.useDelimiter("");

        while (colReader.hasNext()) {
            ++columns;
            ++j;
            System.out.println(colReader.next() + " ");
        }
    }

    matrix = new String[rows][columns];


    System.out.println("Columns " + columns);
    System.out.println("Lines " + rows);

    scanner = new Scanner(new File(fileName));
    for (int i = 0; i &lt; rows; ++i) {
        for (int j = 0; j &lt; 43; ++j) {
            if (scanner.hasNext()) {
                matrix[i][j] = scanner.next();
            }
        }
    }

    for (int i = 0; i &lt; rows; ++i) {
        for (int j = 0; j &lt; 43; ++j) {
            if (scanner.hasNext()) {
                System.out.println(matrix[i][j]);
            }
        }
    }

    scanner.close();
    colReader.close();

}

public static void main(String[] args) throws FileNotFoundException {
    new Main();

}
</code></pre>

<p>File <code>Lab.txt</code>:</p>

<pre class="lang-none prettyprint-override"><code>1111111111111111111111111111111111111111111 
1000000010001000001000000010000000100000001 
1010111010101010101111101011111010111111101 
1010001010100010100000001010000010000010001 
1011101010111110101111111010111111111010111 
.... and so on...(33 rows)
</code></pre>