Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 50
Registered: ‎12-11-2010
My Device: nil

BrowserFieldDemo

I am using a sample similar to BrowserFieldDemo, inwhich i am reading the http response from a server page.

 

HttpConnection conn = (HttpConnection) Connector.open(_url);
         
            if(conn.getResponseCode() == HttpConnection.HTTP_OK)
            {
                InputStream input = conn.openInputStream();


Option 1:                byte[] data = IOUtilities.streamToBytes(input);
                                 response = new String(data);

 

Option2:                byte[] data = new byte[512];
                               int len = 0;
                               StringBuffer raw = new StringBuffer();
        
                               while( -1 != (len = input.read(data))) {
                                     raw.append(new String(data, 0, len));
                               }
            
                              response = raw.toString();

 

                input.close();

          }

 

I am getting correct reponse when i am running the application using simulator.

 

But when running on the device, the response string seems different.

I am not getting the correct response either by attaching the connection strings for WIFI / 3G.

 

Please provide your valuable suggestions to overcome this issue.