判断字符串是否为数字

public static boolean isValidNumber(String str) {
    Pattern pattern = Pattern.compile("^[-\\+]?[.\\d]*$");
    return pattern.matcher(str).matches();
}
posted @ 2019-04-22 20:03  慢慢行  阅读(26)  评论(0)    收藏  举报