(一)利用正则表达式判断某个字符串是否是数字
public static boolean isNumeric(String s) {// 正则表达式return (s.matches("\\d*") && Pattern.compile("[0-9]*").matcher(s).matches());}
(二)利用格式转换异常来确定
// 判断字符串是否为数字public boolean isInteger(String value) {try {Integer.parseInt(value);return true;} catch (NumberFormatException e) {return false;}}