Hi all,
I encounter the error java.util.NoSuchElementException when my program runs.
The error occurs at the codes below:
StringTokenizer reader = new StringTokenizer (line, "\n\t\r "
;
..
while (reader.hasMoreTokens()) {
System.out.println(reader.nextToken());
System.out.println(reader.nextToken());
..
The first element can be printed out during runtime but the error would appear directly after that.
I am wondering if there is anything wrong with my codes above.
My input file
==============
JOB
ARRIVAL 20
CPU 50
IO 50
CPU 50
IO 50
END
JOB
ARRIVAL 30
CPU 150
IO 250
END
JOB
ARRIVAL 1500
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
END
I encounter the error java.util.NoSuchElementException when my program runs.
The error occurs at the codes below:
StringTokenizer reader = new StringTokenizer (line, "\n\t\r "
..
while (reader.hasMoreTokens()) {
System.out.println(reader.nextToken());
System.out.println(reader.nextToken());
..
The first element can be printed out during runtime but the error would appear directly after that.
I am wondering if there is anything wrong with my codes above.
My input file
==============
JOB
ARRIVAL 20
CPU 50
IO 50
CPU 50
IO 50
END
JOB
ARRIVAL 30
CPU 150
IO 250
END
JOB
ARRIVAL 1500
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
CPU 50
IO 250
END