开发者

Blackberry: (Java) Post/Get data

开发者 https://www.devze.com 2023-01-03 18:36 出处:网络
I\'m writing a little application for my BlackBerry and I need to send some data to a webpage (Via GET or POST)

I'm writing a little application for my BlackBerry and I need to send some data to a webpage (Via GET or POST)

Can anyone ad开发者_JAVA百科vise on the way to do this with the BlackBerry.


You need javax.microedition.io.HttpConnection for this. The linked javadoc contains basic code examples for both GET and POST. Here's an extract of the GET example:

 void getViaStreamConnection(String url) throws IOException {
     StreamConnection c = null;
     InputStream s = null;
     try {
         c = (StreamConnection)Connector.open(url);
         s = c.openInputStream();
         int ch;
         while ((ch = s.read()) != -1) {
             ...
         }
     } finally {
         if (s != null)
             s.close();
         if (c != null)
             c.close();
     }
 }
0

精彩评论

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

关注公众号