title: Using StringTokenizer to convert a .txt file into a 2d array
body: <p>Text file(twodimension8.txt). The first line is the rows and cols separated by ','</p>
  <pre><code>4,6
  1,2,3,4,5,6
  23,55,34,89,41,72
  9,27,19,56,33,82
  3,65,21,66,85,11
  </code></pre>
  <p>My Code so far.
  uses TextFileInput class to read from a file</p>
  <pre><code>import java.util.*;
  
  public class Tokens {
     public static TextFileInput myFile;
     public static StringTokenizer myTokens;
     public static int[][] twodimarr;
     public static String line;
     
   
     public static void main(String[] args) {
  
        myFile = new TextFileInput(&quot;twodimension8.txt&quot;);
        line = myFile.readLine();
        System.out.println(&quot;The input line is &quot;+line);
  
        myTokens = new StringTokenizer(line,&quot;,&quot;);
  
        int row = Integer.parseInt(myTokens.nextToken());
        int col = Integer.parseInt(myTokens.nextToken());
  
        twodimarr = new int[row][col];
  
        for (int i = 0; i &lt; row; i++) {
            line = myFile.readLine();
            for (int j = 0; j &lt; col; j++) {
               myTokens = new StringTokenizer(line, &quot;,&quot;);
               twodimarr[i][j] = Integer.parseInt(myTokens.nextToken());
            }
        }
  
        for (int i=0; i&lt;row; i++) {
            for (int j=0; j&lt;col;j++)
               System.out.print(twodimarr[i][j]);
            System.out.println();
      }
           
     } //main
  }
  </code></pre>
  <p>The output:</p>
  <pre><code>111111   
  232323232323
  999999     
  333333  
  </code></pre>
  <p>where the problem seems to be is the for loop where it trys to add it into the 2d array. I'm not sure on how I would fix this.</p>