Package com.yuninfo.util; /** * Get mobile operator * Classname:mobileutil * Description:todo * @author Lizheng * @param args * @date May 30, 2012 8:58: AM * * @version/public class Mobileutil {/** * To determine the number of incoming parameter numbers for which operator * @param mobile * @return Operator Name * * * Public
static string Validatemobile (String mobile) {string returnstring= ""; if (Mobile==null | | Mobile.trim (). Length ()!=11) {return "-1";
The mobile parameter is empty or the cell phone number is not 11 long, error. } if (Mobile.trim (). substring (0,3). Equals ("134") | |
Mobile.trim (). substring (0,3). Equals ("135") | | Mobile.trim (). substring (0,3). Equals ("136") | | Mobile.trim (). substring (0,3). Equals ("137") | | Mobile.trim (). substring (0,3). Equals ("138") | | Mobile.trim (). substring (0,3). Equals ("139") | |
Mobile.trim (). substring (0,3). Equals ("150") | | Mobile.trim (). substring (0,3). Equals ("151") | | Mobile.trim (). substring (0,3). Equals ("152") | | Mobile.trim (). substring (0,3). Equals ("157") | | Mobile.trim (). substring (0,3). Equals ("158") | | Mobile.trim (). SubstrinG (0,3). Equals ("159") | | Mobile.trim (). substring (0,3). Equals ("187") | | Mobile.trim (). substring (0,3). Equals ("188")) {returnstring= "1";//China Mobile} if (Mobile.trim (). substring (0,3). Equals ("13 0 ") | |
Mobile.trim (). substring (0,3). Equals ("131") | | Mobile.trim (). substring (0,3). Equals ("132") | | Mobile.trim (). substring (0,3). Equals ("156") | | Mobile.trim (). substring (0,3). Equals ("185") | | Mobile.trim (). substring (0,3). Equals ("186")) {returnstring= "2";//China Unicom} if (Mobile.trim (). substring (0,3). Equals ("13 3 ") | |
Mobile.trim (). substring (0,3). Equals ("153") | | Mobile.trim (). substring (0,3). Equals ("180") | | Mobile.trim (). substring (0,3). Equals ("189")) {returnstring= "3";//China Telecom} if (Returnstring.trim (). Equals ("")) {Retu rnstring= "0";
Unknown operator} return returnstring;
public static void Main (string[] arg) {mobileutil util=new mobileutil ();
System.out.println (Util.validatemobile ("13999889090"));
System.out.println (Util.validatemobile ("13418170986")); SysteM.out.println (Util.validatemobile ("15392496493"));
System.out.println (Util.validatemobile ("13399889090"));
System.out.println (Util.validatemobile ("erot4543545"));
System.out.println (Util.validatemobile ("erot543545"));
}
}