I'm currently working with the Java Scanner class and I'm getting a very strange InputMismatchException. I initialize the scanner like this:
Scanner in = new Scanner(new File(fileName));
in.useDelimiter("\n?.*:");
When I call System.out.println(in.next());
, it prints 1500
to the command line, which is the correct value. However, if I call System.out.println(in.nextInt());
the Scanner throws an InputMismatchException. I don't think I'm printing trailing newlines or whitespace, and I'm sort of lost as to why this is happening.
EDIT: Here's the data format for what I'm reading in:
Data Description:100
Next Data Description:200
EDIT: Calling Integer.parseInt(in.next());
results in a NumberFormatException: For input string: "1"00
.