判断字符串是否是数字

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));
    }
}

  



posted @ 2018-09-12 18:05  爱吃橙子  阅读(193)  评论(0编辑  收藏  举报