Vala read file line by line
<pre><code>int n = sc.nextInt();
char[][] original = new char[n][n];
char [][] result = new char[n][n];
String line;

for (int i = 0; i &lt; n; i++) {
  line = sc.nextLine();
  System.out.println(line);
  for (int u = 0; u &lt; n; u++) {
    original[i][u] = line.charAt(u);
  }
}

for (int i = 0; i &lt; n; i++) {
  line = sc.nextLine();
  for (int u = 0; u &lt; n; u++) {
    result[i][u] = line.charAt(u);
  }
}
</code></pre>

<p>I have a file that looks like this:</p>

<pre><code>2
ha
ah
lo
ol
</code></pre>

<p>I have an integer N on firs line, and then two N*N matrixes of characters.</p>

<p>I am trying to read them to two arrays of arrays of chars, but I get this error:</p>

<p>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.lang.String.charAt(String.java:695)
    at transform.main(transform.java:25)</p>

<p>Line 25 is this:</p>

<pre><code>original[i][u] = line.charAt(u);
</code></pre>

<p>I just don't get it, I think I'm doing everything just fine. Any ideas? Thank you!</p>
