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

これは次のリンクから入手できます........

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

于 2011-09-03T09:56:48.543 に答える
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 に答える