title: How to read from File into 2d char Array
body: <p>I'm trying to figure out how to read from a txt which looks like this:  </p>
  
  <pre><code>12  
  12  
  WWWWWWWWWWWW   
  W3000000000W  
  W0000000000W  
  W0000000000W   
  W0000000000W  
  W0000000000W  
  W0000000040W  
  W0000000000W  
  W0000000000W  
  W0000000000W  
  W0000000000W  
  WWWWWWWWWWWW  
  </code></pre>
  
  <p>Into a <code>String[][]</code>;</p>
  
  <p>The first 2 lines are the size of the <code>String[][]</code>.
  This is the code which says</p>
  
  <blockquote>
    <p><strong>Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1</strong> at <em>map[i][j] = temp[j].toString();</em></p>
  </blockquote>
  
  <pre><code>public String[][] read() throws IOException{
      BufferedReader br = new BufferedReader(new FileReader("D:/College/Java Eclipse/Map.txt"));   
      String line = " ";
  
  
      int columnCount = Integer.parseInt(br.readLine());
      int rowCount = Integer.parseInt(br.readLine()); 
  
      String[] temp;
      String[][] map = new String[rowCount][columnCount];
  
      while ((line = br.readLine())!= null){ 
          temp = line.split("\\s+"); 
  
          for(int i = 0; i&lt;rowCount; i++) {
              for (int j = 0; j&lt;columnCount; j++) {    
                  map[i][j] = temp[j].toString();
              }
          }
  
      }
      br.close();
      return map;
  
  }
  </code></pre>
  
  <p>What is wrong i can't figure out?</p>