How to use Scanner in java to count the number of words seperate by "," from a input .txt file?
<p>My input file look like this:</p>

<pre><code>1,2,3,4,5,6
3,4,5,6,7,8
5,6,7,8,9,9
1,2,3,4,5,6
</code></pre>

<p>I want to count the number of word in a column and the number of rows so that I can know the array size and put them into a 2D array.</p>

<p>How can I get the number of column and rows? 
Thanks!!!!</p>

<p>My code:</p>

<pre><code>public static void main(String[] args) throws IOException {

        File file = new File("test.txt");
        Scanner input = new Scanner(file);
        BufferedReader bufRdr  = new BufferedReader(new FileReader(file));
        String line = null;

        int i = 0;
        int j = 0;
        int row = 0;
        int col = 0;
        String [][] data = new String [i][j];


        while((line = bufRdr.readLine()) != null)
        {   
        StringTokenizer st = new StringTokenizer(file,",");

        while (st.hasMoreTokens()){ 
          i++;
        }
        while(input.hasNextLine()) {

          String tmp=input.nextLine();

          j++;

        }
        System.out.println(i);
        System.out.println(j);
</code></pre>
