Using Java to judge the operator of mobile phone number

Source: Internet
Author: User
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"));
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.