判断字符串是否是数字

public class IsString {
    public static boolean isNum(String str){
        return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
    }
    @Test
    public void test(){
        String str = "12344.33";
        System.out.println(IsString.isNum(str));
    }
}

  



原文地址:https://www.cnblogs.com/fulucky/p/9636407.html