This particular part of my project requires me to find an employee ID in an array, then read in the next line as a number of hours. How I'm doing all this doesn't really matter, but when I run the program I get "Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at TestEmp.main(TestEmp.java:107)"
...which makes me think that I'm reading through the file wrong.
Scanner newfile = new Scanner(new FileReader("Hourly.dat")); int search; int index; while(newfile.hasNext()) { search = newfile.nextInt(); index = bsearch(empArray, 0, i, search); if(empArray[index].getType()== 'H'){ ((Hourly)empArray[index]).setHours(newfile.nextFloat()); newfile.nextLine(); } } newfile.close();
and the file I'm reading:
3212 92.50
3333 100.00
3999 85.00
3112 80.00
3444 81.00
3987 90.00
3564 80.00
3215 80.00
3665 87.00
3985 88.00
Any ideas to fix this problem would be appreciated.


LinkBack URL
About LinkBacks
Reply With Quote



