/** * 判斷字符串是否爲數字(正整數和浮點數) * @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;}