/** Determine which of the following numbers is China Unicom, China Mobile, and China Telecom,
- * Before using this method, verify the validity rules of the number:
- *
- * China Mobile has 16 segments: 139,138,137,136,135,134,147,159,158,157 (3G), 151,152,150,182 (3G), 188 (3G), 187 (3G)
- * China Unicom has the following code segments: 130,131,132,145,155,156 (3G), 186 (3G), 185 (3G), and 8 Number segments.
- * China Telecom has the following code segments: 133,1349, 153,189 (3G), 180 (3g), and 5
- * @ Param Mobile: number to be determined
- * @ Return returns the corresponding type: 1 represents China Unicom; 2 represents China Mobile; 3 represents China Telecom.
- */
- Public String getmobiletype (string mobile ){
- If (mobile. startswith ("0") | mobile. startswith ("+ 860 ")){
- Mobile = Mobile. substring (mobile. indexof ("0") + 1, mobile. Length ());
- }
- List chinaunicom = arrays. aslist (New String [] {"130", "131", "132 ",
- "145", "155", "156", "186", "185 "});
- List chinamobile1 = arrays. aslist (New String [] {"135", "136", "137 ",
- "138", "139", "147", "150", "151", "152", "157", "158", "159", "182 ", "187 ",
- "188 "});
- 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"; // China Unicom
- If (bolchinamobile1 | bolchinamobile2)
- Return "2"; // move
- Return "3"; // others are Telecom
- }