开发者

BlackBerry HttpConnection Content of URL

开发者 https://www.devze.com 2023-03-31 15:49 出处:网络
I make HttpConnection by the following way: try { StreamConnection s = (StreamConnection)Connector.open(url);

I make HttpConnection by the following way:


try {
   StreamConnection s = (StreamConnection)Connector.open(url);
   HttpConnection httpCon开发者_开发技巧n = (HttpConnection)s;                             
} catch (Exception e) {
   Dialog.alert(e.getMessage());
}

How can I get the content of the url (the text inside the url html file)

Thanks,


Thry something like this:

 StreamConnection c = null;
 InputStream s = null;
 byte[] response;
 try {
     c = (StreamConnection)Connector.open(url);
     s = c.openInputStream();
     response = IOUtilities.streamToBytes(s);
 } finally {
     if (s != null)
         s.close();
     if (c != null)
         c.close();
 }
 String html = new String(response);


You can get this by the following link.........

http://supportforums.blackberry.com/t5/Java-Development/Want-to-get-Response-from-the-particular-URL/m-p/1291627#M172814

0

精彩评论

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