判断手机的访问

目前,中国电信发布中国3G号码段,3G业务专属的180-189号段已基本分配给各运营商使用,中国联通185,186;中国移动188,187;中国电信189,180共6个号段。
  
   至此,中国三大运营商重组后的3G手机使用号段及各运营商号码段分别为:
  
   中国移动拥有号码段为:134、135、136、137、 138、139、158、159、157(TD专属号段)、150、151、187(3G)、188(3G)13个号段
  
   中国联通拥有号码段为:130、131、132、156、186(3G)、185(3G);6个号段
  
   中国电信拥有号码段为:133、153、189(3G)、 180(3G);4个号码段
  
   判断号码的java程序:
  
  /**
   * 判断号码是联通,移动,电信中的哪个,
   * 在使用本方法前,请先验证号码的合法性 规则:前三位为130-133 联通 ;前三位为135-139或前四位为1340-1348 移动; 其它的应该为电信
   * @param mobile要判断的号码
   * @return 返回相应类型:1代表联通;2代表移动;3代表电信
   */
   public static String getMobileType(String mobile) {
   if(mobile.startsWith("0") || mobile.startsWith("+860")){
   mobile = mobile.substring(mobile.indexOf("0") + 1, mobile.length());
   } <script language="JavaScript" type="text/javascript"></script>
   List chinaUnicom = Arrays.asList(new String[] {"130","131","132","133"}) ;
   List chinaMobile1 = Arrays.asList(new String[] {"135","136","137","138","139","158","159"}) ;
   List chinaMobile2 = Arrays.asList(new String[] {"1340","1341","1342","1343","1344","1345","1346","1347","1348"}) ;
  
   boolean bolChinaUnicom = (chinaUnicom.contains(mobile.substring(0,3))) ;
   boolean bolChinaMobile1 = (chinaMobile1.contains(mobile.substring(0,3))) ;
   boolean bolChinaMobile2 = (chinaMobile2.contains(mobile.substring(0,4))) ;
  
   if (bolChinaUnicom)
   return "1" ;//联通
   if ( bolChinaMobile1 || bolChinaMobile2 )
   return "2" ; //移动
   return "3" ; //其他为电信
   }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值