So I want to read a file, that contains numbers separated by spaces. For example, the file "try.txt" content is:
1 2 3
4 5 6
7 8 9
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:
int i,j;
Scanner sc
for(i=0;i<array.length;i++){
for(j=0;j<array[i].length;j++){
array[i][j]=sc.nextInt();
}
}
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?
Thank you.