Java calls the base station cloud interface Invocation instance

Source: Internet
Author: User

/**

 * @ (#) jizhanyun.com for java * * base station cloud Platform Interface demo for java * * @ Base Station Cloud  * @version 1.00 */ Import Java.io.bufferedreader;import java.io.inputstream;import Java.io.inputstreamreader;import java.net.*;  Import Java.io.ioexception; public class API {        public static String Apikey   &NB Sp;= "1ats2c6d9fff0825da88b864a3d1e034"; Apikey Base Station cloud platform get     public static String MNC       = "0";                                //mnc    public static String lac       = "20857";                            //lac    Public Static String cell      = "59051";                            //cell     public static string Getwebdata (String DOMAIN) {        StringBuffer sb = new StringBuffer ();        InputStream is = NULL;&N Bsp       InputStreamReader ISR = null;        BufferedReader in = null;    &NBSP ;   Try {            Java.net.URL URL = new Java.net.URL (domain);      &NB Sp     is = Url.openstream ();            ISR = new InputStreamReader (IS, "utf-8"); &nbs P           in = new BufferedReader (ISR);            String Line;&nbs P           while (line = In.readline ()) = null) {            &NBSP ;   Sb.append (line) append ("\ n");           }            I N.close ();                   } catch (IOException e) {  &nbsp ; &nbSp       E.printstacktrace ();       }finally {            T Ry {                if (in!=null) {                    In.close ();                    in=null;  &nbsp ;            }                if (isr!=null) {  &N Bsp                 isr.close ();              &NBSP ;     isr=null;               }                if (is!=null) {                    is.close ();                    is=null;               }& nbsp          } catch (IOException e) {                E.printstackt Race ();           }       }        return SB.TOSTR ING ();   }        public static void main (string[] args) {        String data=getwebdata ("http://www.jizhanyun.com/api/?mnc=" +mnc+ "&lac=" +lac+ "&cell=" +cell+ "&ishex= 10&type=1&apikey= "+apikey);        string code=" ";        String about=" ";        string lng=" ";        String lat=" ";        String g Lng= "";        string glat= "";        string address= "";      &NBSP ; if (data!= ") {            string[] Arr=data.split (" \\| ");             code=arr[0];    &NBsp       if (Code.equals ("001")) {                lng=arr[2];  &nbs P             lat=arr[3];                glng=arr[4];& nbsp               glat=arr[5];                Addre ss=arr[6];           }else{                About=ar r[1];           }       }          &nbsp ;     SYSTEM.OUT.PRINTLN ("Status:" +code);        SYSTEM.OUT.PRINTLN ("description:" +about);        SYSTEM.OUT.PRINTLN ("Longitude:" +lng);        System.out.println ("Latitude:" +lat);  & nbsp     SYSTEM.OUT.PRINTLN ("Google Maps Longitude:" +glng);        SYSTEM.OUT.PRINTLN ("Google Maps Longitude:" +glat);         SYSTEM.OUT.PRINTLN ("Address:" +address);     }}

Java calls the base station cloud interface invocation instance

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.