java 手机号本地验证归属地

1. http://repo1.maven.org/maven2/com/googlecode/libphonenumber/

下载依赖包:carrier-1.9.jar  geocoder-2.32.jar  libphonenumber-7.2.2.jar  prefixmapper-2.32.jar

/**查询手机归属地*/
    public static boolean checkPhone(String tel, String _city) {
        PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
        PhoneNumberOfflineGeocoder phoneNumberOfflineGeocoder = PhoneNumberOfflineGeocoder.getInstance();
        String language ="CN";
        Phonenumber.PhoneNumber referencePhonenumber = null;
        try {
            referencePhonenumber = phoneUtil.parse(tel, language);
        } catch (NumberParseException e) {
            e.printStackTrace();
        }
//手机号码归属城市 city
        String city= phoneNumberOfflineGeocoder.getDescriptionForNumber(referencePhonenumber,Locale.CHINA);
        return city.equals(_city);
    }

 

上一篇:杂记


下一篇:mysql 排序表