• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with InputStream.read(bytes)

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
reply
    Bookmark Topic Watch Topic
  • New Topic