***While loop now working, just need an argument for a method.***
I have a text file with 8 lines of information. Each line has an int (UniqueID), a string (name) and 5 doubles (marks). Each item of data is separated bya colon, which I'm using as a delimiter.I've written the following code to read each line and then print out a formatted table of information showing the uniqueID, name and the marks. The marks are to be read as an array(marks[]) and so is the complete table (records[]).
while (inputStream.hasNextLine() && (numUsed < records.length)) { uniqueID = inputStream.nextInt(); name = inputStream.next(); System.out.printf("%7s %8s %-21s", uniqueID, space, name); while (inputStream.hasNextDouble() && (i < marks.length)) { marks[i] = inputStream.nextDouble(); System.out.printf("%9s", marks[i]); i++; } records[numUsed] = inputStream.nextLine(); System.out.println(" "); numUsed++; }
When I run the code the first line prints out correctly but the next seven lines print only the uniqueID and name. Can anyone tell me why it runs through the second while loop the first time through but not on subsequent loops.
p.s. I know the problem isn't in the data file as I use it elsewhere in the program and it runs correctly.
Thank you in advance for any help.