判断字符串是否为正整数 & 浮点小数

/**
* 判断字符串是否为数字(正整数和浮点数)
* @param str
* @return
*/
public static boolean isNumeric(String str) {
String reg = "^[0-9]+(.[0-9]+)?$";
Pattern pattern = Pattern.compile(reg);
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
return false;
}
return true;
}
原文地址:https://www.cnblogs.com/laotan/p/9111051.html