java.lang.NumberFormatException: For input string: “null”

后端 未结 6 1301
独厮守ぢ
独厮守ぢ 2020-12-21 05:16

I\'m parsing a doc and I get the following error:

Exception in thread \"main\" java.lang.NumberFormatException: For input string: \"null\"
    at sun.misc.Fl         


        
6条回答
  •  既然无缘
    2020-12-21 05:58

    The parseInt() and parseDouble() will error with NFE if passed with a null, space or blank string value. Once you have handled the null condition it will still fail with an empty string. Try adding a zero before the empty string like below. It maintains the integrity of calc as well:

    Integer.parseInt(" ".trim())

    to

    Integer.parseInt( "0" + " ".trim())

提交回复
热议问题