- /**
- * <pre>
- Const为常量类或接口
- String TEL_MOBILE = config.get("TEL_MOBILE", "134,135,136,137,138,139,150,158,159"); //移动的号码段
- String TEL_UNICOM = config.get("TEL_UNICOM", "130,131,132,133,153,156"); //联通的号码段
- * 号码段放入配置文件,目前(2007-10-11)的号码段为:
- * 移动:134,135,136,137,138,139,150,158,159
- * 联通:130,131,132,133,153,156
- * </pre>
- * @param tel
- * @return 运营商 (1=移动、2=联通)
- */
- public static byte getTelCompany(String tel)
- {
- String telHead = tel.substring(0, 3);
- if(isMobileUnicom(telHead,1))
- {
- return 1;
- }
- if(isMobileUnicom(telHead,2))
- {
- return 2;
- }
-
- return -1;
- }
-
- private static boolean isMobileUnicom(String telHead,int company)
- {
- String tel = "";
-
- switch(company)
- {
- case 1:
- tel = Const.TEL_MOBILE;
- break;
- case 2:
- tel = Const.TEL_UNICOM;
- break;
- default:
- return false;
- }
-
- String[] aTel = tel.split(",");
-
- int iCount = aTel.length;
- for(int i=0;i<iCount;i++)
- {
- if (aTel[i].equals(telHead))
- {
- return true;
- }
- }
-
- return false;
- }
复制代码 |