title: Java making a 2D list object of a file of numbers
body: <p>I have a pyramid of numbers in a file like</p>
  
  <ul>
  <li>1 </li>
  <li>2 3
  
  <ul>
  <li>3 4 5</li>
  </ul></li>
  </ul>
  
  <p>I'm trying to populate a 2D Arraylist with the numbers from a file. I'm trying to populate first a row of numbers then add that row to a column but I can't find the right input test to get that done. </p>
  
  <pre><code>ArrayList&lt;Integer&gt; rows = new ArrayList&lt;Integer&gt;(); 
  ArrayList&lt;ArrayList&lt;Integer&gt;&gt; columns = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;(); 
      try {
          Scanner s = new Scanner(new File("1.txt"));
          //while (s.hasNext()) {
              String a = s.next();
              String b = s.next();
              s.nextLine();
  
              while(s.hasNextLine()) {
                  while(s.hasNextInt() ) { 
                  // I want to say while( has more lines is true )
                  // ( create a row of ints and append it to columns
                      rows.add(s.nextInt());
  
                      }   
                  columns.add(rows);
                  rows.clear();
              }   
  
      catch (FileNotFoundException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>edit: my last row being added is  [1, 2, 3, 3, 4, 5] instead of [3, 4, 5] because the s.hasNextInt() is always true while iterating,
  so the while(in.hasNextLine()) only runs once</p>