Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 所有代码都无法通过BIS建立http连接_Blackberry_Httpconnection - Fatal编程技术网

Blackberry 所有代码都无法通过BIS建立http连接

Blackberry 所有代码都无法通过BIS建立http连接,blackberry,httpconnection,Blackberry,Httpconnection,我是开发黑莓应用程序的新手 在这三天里,我已经从RIM本身的论坛和教程中进行了搜索和学习。但是没有一个能解决我的问题 试试这个代码 try { HttpConnection httpConnection=(HttpConnection)Connector.open(url); httpConnection.setRequestMethod(HttpConnection.GET); if(httpConnection.getResponseCode()==HttpConn

我是开发黑莓应用程序的新手

在这三天里,我已经从RIM本身的论坛和教程中进行了搜索和学习。但是没有一个能解决我的问题 试试这个代码

 try {

    HttpConnection httpConnection=(HttpConnection)Connector.open(url);
    httpConnection.setRequestMethod(HttpConnection.GET);
   if(httpConnection.getResponseCode()==HttpConnection.HTTP_OK)
   {
     InputStream is=httpConnection.openInputStream();
     int ch;
     StringBuffer buffer=new StringBuffer();
       while((ch=is.read())!=-1)
       {
        buffer.append((char)ch);
      }
     }
    } catch (IOException e) {
        System.out.println("Exception From Thread"+e);
        e.printStackTrace();
    }
}

据我所知,为了使用BIS,您需要成为RIM合作伙伴(需要花钱)。
String url = "myURL";


try {

    StreamConnection s = (StreamConnection)Connector.open(url);

    InputStream input = s.openInputStream();

    Dialog.inform("sblm byte");

    byte[] data = new byte[256];
    int len = 0;
    StringBuffer raw = new StringBuffer();

    Dialog.inform("stlh buat byte");

    while( -1 != (len = input.read(data))) {
        raw.append(new String(data, 0, len));
    }

    Dialog.inform("stlh while");
    response = raw.toString();
    Dialog.inform(response);

    input.close();
    s.close();

} 

        catch(Exception e) { }
 try {

    HttpConnection httpConnection=(HttpConnection)Connector.open(url);
    httpConnection.setRequestMethod(HttpConnection.GET);
   if(httpConnection.getResponseCode()==HttpConnection.HTTP_OK)
   {
     InputStream is=httpConnection.openInputStream();
     int ch;
     StringBuffer buffer=new StringBuffer();
       while((ch=is.read())!=-1)
       {
        buffer.append((char)ch);
      }
     }
    } catch (IOException e) {
        System.out.println("Exception From Thread"+e);
        e.printStackTrace();
    }
}