Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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

readInt returns size is 874520608

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on the URLYBird application
and am using the DataInputStream readInt method
to read the size field. However I get really large
values like:

size is 874520608

The rest of the fields seem to read in fine.

Any ideas?
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like one of two things is happening:

1. You're not aligning your reads correctly (are you sure you are reading at the correct offset?)
2. You're not interpreting the data correctly (not an int? wrong endian?)

Is the data after the size field being read properly? I don't know about your assignment, so I can't make any presumptions, like, the data after size is 'size' bytes.

Reading your resource as a stream of bytes (if it's a file, view the file with some binary file viewer, or print out the stream of bytes to stdout, or use the Unix or Cygwin tool 'od') to make sure you're actually reading everything correctly up to that point.

Finally, try to step through it with a debugger.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Robert Konigsberg:
It sounds like one of two things is happening:

1. You're not aligning your reads correctly (are you sure you are reading at the correct offset?)



I second this hypothesis. The int you are reading could be converted to a four character string containing "4 " (a number 4 and three whute space characters). Perhaps you are trying to read a string-typed field?

In my assignment (B&S) all record data is string typed; only in the schema description part do I need to use readInt.

Frans.
 
Robert Konigsberg
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to be a PITA, it sounds like you actually 'second' my second hypothesis. Yes?
 
Robert Konigsberg
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PS good analysis!
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Robert Konigsberg:
Just to be a PITA, it sounds like you actually 'second' my second hypothesis. Yes?



Ehm, yes, that one too

But I thought I'd focus on the first one, because that is the most probable cause of the misinterpreting.

Frans.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic