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