Hello and Happy holidays to all. I am new here, so sorry to bother you. I'm working on a project for a class and have run into a bit of a snag. I have a method that reads integer values from a text file and stores them into an array for use later on. The problem is, every time I try to run the program, I get an input mismatch exception, I'm scanning for integers and the only thing in the file is integers so I don't understand why this isn't working. I have tried commenting out the loop and putting generic System.out.print(scanner.next()); statements in to see what it is actually reading. when I try that it prints the title of the file "testit", but after that it finds nothing hence the NoSuchElementException. So I dont think the file is reading properly or something. any insight on this would be very helpful.
OG method:
public int[][] readData()
{
int[][] dataArray = new int[200][4];
while(fileRead.hasNext())
{
for(int i = 0; i<= 200; i++)
{
dataArray[i][0] = fileRead.nextInt();
dataArray[i][1] = fileRead.nextInt();
dataArray[i][2] = fileRead.nextInt();
dataArray[i][3] = fileRead.nextInt();
}
}
return dataArray;
}
**fileRead is the Scanner
testit.txt:
1234 300 500 200
1235 200 500 300
1236 200 300 500
1237 500 200 300
1238 500 300 200