方法1:
public static boolean isNumber(String str){
Pattern pattern = Pattern.compile("\\d+");
Matcher num = pattern.matcher(str);
if (!num.matches()) {
return false;
}
return true;
}
方法2:
public static boolean isNum(String str) {
Pattern pattern = Pattern.compile("[0-9]*");
Matcher num = pattern.matcher(str);
if (!num.matches()) {
return false;
}
return true;
}