Forums Register Login

urlyBird requirement clarification

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 657 times.
Similar Threads
RAF || DIS
Data file
URLyBird--Data file
How to read MAGIC for db-2x2.db
NX: Reading Database
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:05:09.