public static boolean checkNum(String num) 
    {  
        try{            
            Pattern pattern = Pattern.compile("^[0-9]+(.[0-9]{1,3})?$");
            Matcher matcher = pattern.matcher(num);
            return matcher.matches();

        } 
        catch(Exception e){
            e.printStackTrace();
        }
        return false; 
    }