Exception in thread "Thread-2" java.lang.NumberFormatException: For input string: "3"
int test = Integer.parseInt(result[0]);
This is the error I keep getting when I'm trying to convert "3" to an integer. Well I'm receiving this "3" through a RS-232 port, so maybe this is what is causing the error.
If anybody has any idea what could be causing this it would be appreciated.
What is the data type of result[0]? If it's a string, are you sure there are no spaces or new lines around it?
Try result[0].trim()
Take a look at the char values of result[0]
when this occurs. It might be possible that this "3" is in fact not the ASCII character '3' but some strange Unicode character that just looks like a 3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With