title: How can I determine what I read from a file? Java
body: <p>So I want to read a file, that contains numbers separated by spaces. For example, the file "try.txt" content is:</p>
  
  <p>1 2 3<br>
  4 5 6<br>
  7 8 9</p>
  
  <p>I know how to read this numbers and store them in an array with a Scanner, and two nested for loops.Ignore any possible sintax errors here. It would look like: </p>
  
  <pre><code>int i,j;
  Scanner sc
  for(i=0;i&lt;array.length;i++){
     for(j=0;j&lt;array[i].length;j++){
        array[i][j]=sc.nextInt();
     }
  }
  </code></pre>
  
  <p>So my question is, how can I check that what I am reading is actually an integer? What happens if nextInt() finds a letter, or another ASCII symbol?</p>
  
  <p>Thank you.</p>