Proper way to avoid parseInt throwing a NumberFormatException for input string: “”

后端 未结 7 845
小鲜肉
小鲜肉 2020-12-06 09:53

When I run parseInt:

Integer.parseInt(myString);

it throws:

NumberFormatException: For input string: \"\"

7条回答
  •  既然无缘
    2020-12-06 10:51

    Yes. (Validate your inputs before making assumptions about what are in them. :-)

    +1 for already finding Apache's common-lang w/ StringUtils.

提交回复
热议问题