开发者

BlackBerry HttpConnection Content of 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜