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.
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.
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.
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?