(轉)java判斷string變數是否是數字的六種方法小結
阿新 • • 發佈:2019-02-12
org.apache.commons.lang.StringUtils; boolean isNunicodeDigits=StringUtils.isNumeric("aaa123456789"); http://jakarta.apache.org/commons/lang/api-release/index.html下面的解釋: public static boolean isNumeric(String str)Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false. null will return false. An empty String ("") will return 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