• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with InputStream.read(bytes)

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My midlet connects to a servlet using HttpConnection. It works fine on all phones that I've tested on, except Sony Ericsson T610.

The midlet correctly reports the content-length (which is always > 300), but my code...



prints out that 'actual' is exactly 100 every time, and no exception is caught.

So can anyone help me as to why only 100 bytes might be read, rather than the full 300+.

I've tried not setting the content-length header in the servlet (so my midlet reads one byte at a time, but I get exactly the same result.

Any help or workaround suggestions would be really appreciated.

Thanks,
James
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with your particular setup, but why do you expect one call to read( byte[] ) to read the entire message? Why not accumulate bytes until an end-of-file is reached?
Bill
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought it would read the entire message, as that would seem to be the logical thing to do. But, having read the javadoc more closely, I realise that it doesn't necessarily have to do that.

However, like I say, I only get this problem on the Sony Ericsson T610 - every other phone I work with reads the entire message.

As you suggested, I have now got it reading in a byte at a time. Again though, there was a slight difference with the behaviour on T610 as compared to other phones in that (for some unknown reason(?)) the T610 throws an IOException after reading the last byte, but if I ignore it all is well.

Thanks,
James
 
Arun Soman
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
checkout the http implementation in "Sony Ericsson T610". ie which version does it implements 1.0 or 1.1, i think ur content is comming as "chunked".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic