【问题标题】:java.lang.NumberFormatException on parsing with commons-digester使用 commons-digester 解析时出现 java.lang.NumberFormatException
【发布时间】:2011-03-24 16:16:56
【问题描述】:

我在使用 commons-digester 解析 xml 文件时遇到 java.lang.NumberFormatException。

不知道是什么意思:

Caused by: java.lang.NumberFormatException: For input string: "flickrmeetup rochester dan totheright 200701"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:449)
    ...

这是完整的错误信息:http://pastie.org/1708720

这是代码:http://codepad.org/tw39paE1

谢谢

【问题讨论】:

    标签: java apache-commons-digester


    【解决方案1】:

    您似乎已将flickrmeetup rochester dan totheright 200701 传递给Integer.parseInt(),这是不可接受的

    【讨论】:

      【解决方案2】:

      当传递给函数的字符串不包含可解析的 int 时,Integer.parseInt() 会抛出“NumberFormatException”。

      传递给函数的字符串是“flickrmeetup rochester dan totheright 200701”。您需要传递一个仅包含数字值的字符串。例如:“0”、“1234”、“999”。

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多