Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if must use DataInputStream ?

 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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
 
Serkan Yazici
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Mike Keller
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic