StringUtils.isNumeric("")竟然返回true

 * 
     * StringUtils.isNumeric(null)   = false
     * StringUtils.isNumeric("")     = true
     * StringUtils.isNumeric("  ")   = false
     * StringUtils.isNumeric("123")  = true
     * StringUtils.isNumeric("12 3") = false
     * StringUtils.isNumeric("ab2c") = false
     * StringUtils.isNumeric("12-3") = false
     * StringUtils.isNumeric("12.3") = false
     * 
* *
@param str the String to check, may be null * @return true if only contains digits, and is non-null */ public static boolean isNumeric(String str) { if (str == null) { return false; } int sz = str.length(); for (int i = 0; i < sz; i++) { if (Character.isDigit(str.charAt(i)) == false) { return false; } } return true; }
复制代码

 

 

https://issues.apache.org/jira/browse/LANG-428

  • Type: Bug
  • Status: Closed
  • Priority: Minor
  • Resolution: Fixed
  • Affects Version/s: 2.3
  • Fix Version/s: 3.0
  • Component/s: lang.*
  • Labels:
    None

3.0版本已经解决该问题

分类: JAVA

你可能感兴趣的:(StringUtils.isNumeric("")竟然返回true)