移动联通和电信的号段判断

 
            /**    判断号码是联通,移动,电信中的哪个, 
  1.  * 在使用本方法前,请先验证号码的合法性 规则: 
  2.  *   
  3.  * 中国移动拥有号码段为:139,138,137,136,135,134,147,159,158,157(3G),151,152,150,182(3G),188(3G),187(3G);16个号段 
  4.  * 中国联通拥有号码段为:130,131,132,145,155,156(3G),186(3G),185(3G);8个号段 
  5.  * 中国电信拥有号码段为:133,1349,153,189(3G),180(3G);5个号码段 
  6.  * @param mobile要判断的号码 
  7.  * @return 返回相应类型:1代表联通;2代表移动;3代表电信 
  8.  */  
  9. public String getMobileType(String mobile) {  
  10.   
  11.         if (mobile.startsWith("0") || mobile.startsWith("+860")) {  
  12.         mobile = mobile.substring(mobile.indexOf("0") + 1, mobile.length());  
  13.     }  
  14.     List chinaUnicom = Arrays.asList(new String[] { "130""131""132",  
  15.             "145","155""156""186""185" });  
  16.     List chinaMobile1 = Arrays.asList(new String[] { "135""136""137",  
  17.             "138""139""147","150""151""152""157""158""159""182","187",  
  18.             "188" });  
  19.     List chinaMobile2 = Arrays.asList(new String[] { "1340""1341",  
  20.             "1342""1343""1344""1345""1346""1347""1348" });  
  21.   
  22.     boolean bolChinaUnicom = (chinaUnicom.contains(mobile.substring(03)));  
  23.     boolean bolChinaMobile1 = (chinaMobile1  
  24.             .contains(mobile.substring(03)));  
  25.     boolean bolChinaMobile2 = (chinaMobile2  
  26.             .contains(mobile.substring(04)));  
  27.     if (bolChinaUnicom)  
  28.         return "1";//联通    
  29.     if (bolChinaMobile1 || bolChinaMobile2)  
  30.         return "2"//移动    
  31.     return "3"//其他为电信    
  32.   
  33. }  
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值