java.lang.NumberFormatException for input string “1”

前端 未结 1 1839
无人共我
无人共我 2021-01-17 07:55

So, I have an issue that really bothers me. I have a simple parser that I made in java. Here is the piece of relevant code:

while( (line = br.readLine())!=nu         


        
相关标签:
1条回答
  • 2021-01-17 08:07

    You have a BOM in front of that number; if I copy what looks like "1" in your question and paste it into vim, I see that you have a FE FF (e.g., a BOM) in front of it. From that link:

    The exact bytes comprising the BOM will be whatever the Unicode character U+FEFF is converted into by that transformation format.

    So that's the issue, consume the file with the appropriate reader for the transformation (UTF-8, UTF-16 big-endian, UTF-16 little-endian, etc.) the file is encoded with. See also this question and its answers for more about reading Unicode files in Java.

    0 讨论(0)
提交回复
热议问题