Reputation: 482
I am trying to parse some integers in loop. Some of them are throwing NumberFormatException
weirdly because it shows error :-
java.lang.NumberFormatException: For input string: "600"
The line that throws error :-
closingPoints += Integer.parseInt(tokens[i + 1]);
Upvotes: 0
Views: 74
Reputation: 1369
You have non-printable / Non-ASCII characters on your String. You can try to remove them using a regular expression. For example
closingPoints += Integer.parseInt(tokens[i + 1].replaceAll( "[^\\x00-\\x7F]", "" ));
What the above regex does is to replace all characters that are not (^) between the hexadecimal range of 00-7F (0-127) which is the range of ASCII characters. If a character on that range is found, it replaces it with empty String.
Upvotes: 3
Reputation: 533
Check that you do not have:
Upvotes: 2