/**
* 判断字符串是否为数字(正整数和浮点数)
* @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