开发者

how can i connect my blackberry app to my website rest API?

开发者 https://www.devze.com 2023-04-08 00:47 出处:网络
I am trying开发者_运维问答 to build my first app for blackberry mobile\'s but i am new @ mobile development and i am cant find the correct way to connect my app with my webiste rest API can anyone gui

I am trying开发者_运维问答 to build my first app for blackberry mobile's but i am new @ mobile development and i am cant find the correct way to connect my app with my webiste rest API can anyone guide me where to start from?

Thanx in advance :D


    HttpConnection conn = null;
    InputStream is = null;
    ByteArrayOutputStream bos = null;
    String response = null;
    String connectionURL = null;



    try {

        connectionURL = "THIS CONTAIN YOUR API URL"

        conn = (HttpConnection) Connector.open(connectionURL);
        conn.setRequestProperty("Content-Type","application/json");
        System.out.println("Response code : "+conn.getResponseCode());

        if(conn.getResponseCode() == HttpConnection.HTTP_OK)
        {

            is = conn.openInputStream();
            int ch=-1;
            bos = new ByteArrayOutputStream();
            while((ch = is.read())!=-1)
            {
                bos.write(ch);
            }
            response = new String(bos.toByteArray());
            System.out.println("Response : "+response);
        }
    } catch (Exception e) 
    {
        System.out.println("Exception .."+e);

    }finally 
    {

            if(conn != null)
                conn.close();
            if(is != null)
                is.close();
            if(bos != null)
                bos.close();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号