JAVA判断字符串是不是数字格式
代码如下:
public static boolean valIsNumber(String value) {
Pattern pattern = Pattern.compile("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
Matcher isNum = pattern.matcher(value);
if (!isNum.matches()) {
return false; //不是数字
}
return true; //是数字
}

浙公网安备 33010602011771号