0

我通过以下方式制作 HttpConnection:


try {
   StreamConnection s = (StreamConnection)Connector.open(url);
   HttpConnection httpConn = (HttpConnection)s;                             
} catch (Exception e) {
   Dialog.alert(e.getMessage());
}

如何获取 url 的内容(url html 文件中的文本)

谢谢,

4

2 回答 2

1

尝试这样的事情:

 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);
于 2011-08-29T08:14:11.473 回答
1

您可以通过以下链接获得它......

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

于 2011-09-03T09:56:48.543 回答