• 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

if must use DataInputStream ?

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In instruction, I can't fully understand the intention about accessing db file.

the sentance is "All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes".

Should I use DataInputStream and DataOutputStream to access record from db file ?

but I find it is not convenient to use those classes, I rather use RandomAccessFile class.

regards
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Along,

I think what the instructions want to make clear is don't worry about the endian format for the numbers (In other words, readShort/readInt/writeShort/etc specified in DataOutput and DataInput interfaces and implemented in DataInputStream and DataOutputStream classes will work fine).

Since RandomAccessFile implements both interfaces as well, using RandomAccessFile is fine too. In fact, if Java supported multiple implementation inheritance; RandomAccessFile would probably directly extend DataInputStream and DataOutputStream classes and leave read/write methods intact
 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for response.

It is said that I can use RandomAccessFile to access the db file,but I'm not sure whether doing so deviate Sun's intention,as the instruction expressly say to use DataInputStream.

regards
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They aren't telling you to implement DataInputStream, they are just describing the format of the numbers. DataInputStream and RandomAccessFile both get their functionality reading numbers from the DataInput interface. Don't sweat it.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic