title: Adjacency Matrix java
body: <p>User enters a text file at command-line and my prog. will take the text, create an array with the number of rows (vertices) of the first number showed, then fill the 2d array with the remaining numbers. Finally it will display if <strong>#</strong> connects to <strong>#</strong> display <strong>T</strong>, else display <strong>F</strong>. I haven't completed it, and am stuck on it just filling the array and displaying the numbers in the array. </p>
  
  <pre><code>import java.io.FileNotFoundException;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Scanner;
  
  
  class AdjMatrix {
  
  public static void main(String[] args) {
  
      //ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(); //Arraylist to store all integers in the array
      //int n = 0; //Vertices
      final int COLS = 2; //Number of columns
      int[][] array = null;
      int lineNumber = 0;
      String line = "";
      if(args.length &gt; 0)
      {
          try
          {
              java.io.File file = new java.io.File(args[0]);
              Scanner in = new Scanner(file);
  
              //Reading the file
              while(in.hasNext())
                  {
                  line = in.next();
                  lineNumber++;
                  if(lineNumber == 1)
                  {
                      //n = Integer.parseInt(line);
                      array = new int[Integer.parseInt(line)][COLS];
                      System.out.println(Integer.parseInt(line));
                  }
                  else
                  {
                      String[] tokens = line.split(",");
                      for(int x = 0; x &lt; tokens.length; ++x)
                          for(int j = 0; j &lt; tokens.length; ++j)
                          {
                              array[x][j] = Integer.parseInt(tokens[x]);
                          }
                  }
  
              }
              in.close();
          }//End try 
          catch(FileNotFoundException e)
          {
              System.err.println("File was either not found or it does not exist.");
              System.out.printf("\n");
  
          }//End catch
      }//End Commandline param entry
  
  
      for(int i = 0; i &lt; array.length; i++)
          for(int j = 0; j &lt; array.length; j++)
              System.out.println(" " + array[i][j]);
  
  
  }
  }
  </code></pre>
  
  <p>I put in <code>System.out.println(Integer.parseInt(line));</code> to see if it grabs the number and puts it in the <strong>rows #</strong> for the array, that's successful. Any help is appreciated. Been on it for a good while and any assistance is appreciated.</p>
  
  <p><strong>EDIT</strong>
  Sorry, forgot to add the input file.</p>
  
  <p>integer.txt</p>
  
  <p>9<br>
  1,2<br>
  2,6<br>
  6,2<br>
  5,1<br>
  6,5<br>
  3,2<br>
  6,3<br>
  3,7<br>
  8,7<br>
  9,9  </p>
  
  <p>9 being the number that establishes the # of rows. Then the program grabs all numbers after 9</p>