title: java reading int from file, original method not working looking for something new
body: <p>how can i read int from my file and save it to an arraylist int. The number in the file can either be separated by a comma or a space. I have a code here, but this has a problem(cannot read the first number beginning from the second row). I already abandoned this method and is looking for something new. Thanks for the help.</p>
  
  <p>The file looks like this:</p>
  
  <pre><code>1,2,3 4,7 8
  10 8 7,5,4 0
  </code></pre>
  
  <p>I just posted this here, so you guys know I do have a method. </p>
  
  <pre><code>ArrayList&lt;Integer&gt; listtwo = new ArrayList&lt;&gt;();
  try {
      file = new Scanner(new File(filename+".txt")).useDelimiter(",| ");
  } catch (FileNotFoundException e) {
      e.printStackTrace();
  }
  
  while(file.hasNext()){
      if (file.hasNextInt()){ 
          listtwo.add(file.nextInt());
      }else{
          file.next();
      }
  }
  for (Integer i: listtwo) System.out.println(i);
  </code></pre>