Your while
-loop is not correctly working because you check for fileIn.hasNext()
, but afterwards use fileIn.nextInt()
and fileIn.next()
in different ways.
What you probably want to use is:
while (fileIn.hasNextLine()) {
String line = fileIn.nextLine();
String[] bigParts = line.split(" ");
String[] timeParts = bigParts[0].split(":");
roster.add(new Time(
Integer.parseInt(timeParts[0]),
Integer.parseInt(timeParts[1]),
bigParts[1]
));
}
This reads the file line by line, then takes the line it has read. Following it splits the text up in three parts, first by (blank), then by
:
(colon).
UPDATE: Added Integer.parseInt()
as it was originally done aswell.