Questions tagged [inputmismatchexception]

Use this tag on questions regarding input mismatch exceptions that occur when using the `Scanner` object.

The InputMismathException is a Java I/O exception that is thrown when the Scanner object encounters an input which it does not expect. An example would be expecting a double, but receiving a String token instead. This is a runtime exeception that inherits from NoSuchElementException.

258 questions
-3
votes
2 answers

Why is Scanner.nextDouble throwing a InputMismatchException for numbers separated by "," or ";"?

I am trying to read coordinates from a file. The format is start point, end point, polygons. Here is an example: 1, 3 34, 19 0, 14; 6, 19; 9, 15; 7, 8; 1, 9 2, 6; 17, 6; 17, 1; 2, 1 I read each line using a BufferedReader and have confirmed that…
Pareod
  • 151
  • 1
  • 11
-4
votes
3 answers

Using Try/Catch Block to Identify Strings in File

I am attempting to read a bunch of numbers from a file and add them up. But I have added a few Strings in the File also. I am now trying to read the numbers add them together and using the try/catch block I am trying to display an error when the…
-5
votes
1 answer

Program to get the lowest number in a file

I am trying to make the program access a file name "highscore.txt", then: Write a new number in the file Get the lowest value of a list of numbers in the file. I am new to Java so I barely know how to even access the file. I got code that I…
1 2 3
17
18