aspose file tools*
The moose likes Java Micro Edition and the fly likes Problem reading the HttpConection response in some devices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Problem reading the HttpConection response in some devices" Watch "Problem reading the HttpConection response in some devices" New topic
Author

Problem reading the HttpConection response in some devices

Hernan Nobile
Greenhorn

Joined: Mar 10, 2008
Posts: 1
Hello everybody,

I am having a strange problem when trying to read the response of an HTTPConnection object. The scenario is this:

1) App in the cellphone connects via HTTP to a webpage
2) The webpage adds some text to the response
3) The app in the cellphone tries to get all the text embedded in the HTTP Response.

If I try the code using emulators or some devices ( like motorola devices ) everything works perfect, but when trying with a live Sony Ericsson W200i I cannot read more than 57 bytes
of the response. Here is the sample code:



In the emulator the result is 70 bytes total, 40 bytes in the first read and 30 bytes in the second read.
In the real device the result is 70 bytes total too, but 40 bytes in the first read and only 17 bytes in the second read!!!
I've tried a dozen ways of reading the response buffer (in a loop, by chunks, in one step all togheter, etc.) and always read only 57 bytes.
Any idea???

Thanks!
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
The logic makes sense, if it runs in the simulator but not in the device I think it is a matter for the vendor.
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
To make sure I understand every you tried;

You did try reading from the stream in a while loop, similar to the code below?



If not give it a try.


Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem reading the HttpConection response in some devices