Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

urlyBird requirement clarification

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The requirement says " All numeric are stored in the header information use the formats of the DataInputStream and DataOutputStream classes."


Is there a period after 'header information'?
What does format implies here?
Is sun suggesting to use DataInputStream and DataOutputStream?

I understand that the seek functionality can be attained by specifying offset in readByte(offset, length) command. I wonder what is meant by "the format for DataInputStream". If somebody can put some light in the right direction that will be great.

Thanks in advance.
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its referring to the numerical information with regards to built in data types like short, intetger etc. Basically you have to directly read the data as integers or shorts, and not read them as a string and parse them.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jiju,

Welcome to JavaRanch and this forum.

Sun seem to have found an obscure way of telling us that the data is in a Java readable format. That is, you don't have to worry about whether it uses big-endian data or little-endian data, or converting from EBCDIC or ....

Basically you can use any I/O classes you like. If you want to, you can use DataInputStream and DataOutputStream classes, or you can move to RandomAccessFile (which uses the same underlying data format), or (as long as your instructions don't explicitly dissalow it) any of the NIO classes.

Regards, Andrew
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inuka and Andrew,
Thanks for your time.

Now it is clear to me. Now I am thinking which file accessor class to choose.

RandomAccessFile implements both DataInput and DataOutput.
DataInputStream inplements DataInput
DataOutputStream implements DataOutput

The method I like to use is

readFully(byte[] b, int off, int len) //Reads len bytes from an input stream.

I am curious to know which among DataXXputStream (XX-in, out) and RandomAccessFile is more effecient and flexible.

Some thoughts I came across are
1. having separate reader and writer objects appeals to me for the code can be synchronozed on writer object.
2. having RandomAccessFile will enable us to have a single object to do read and write.

What else should I consider in choosing file accessor class?
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I found the answer to my question.
RandomAccessFile is appropriate since it have the seek method.

The offset in
readFully(byte[] b, int off, int len)
will not replace seek function as I thought.

off:int (in the signature above) merely specifies a position in b:byte[] array

Jiju
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic