Java判断一个字符串是否是数字:
public static boolean isNumeric(String str) {
Pattern pattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
String bigStr;
try {
bigStr = new BigDecimal(str).toString();
} catch (Exception e) {
e.printStackTrace();
return false;
}
Matcher isNum = pattern.matcher(bigStr);
if (!isNum.matches()) {
return false;
}
return true;
}