/** * 校验字符串是否是纯数字 * * @param str 数字字符串 * @return boolean */ private static boolean isInteger(String str) { String s = "^[-+]?[\\d]*$"; Pattern pattern = Pattern.compile(s); return pattern.matcher(str).matches(); }