The format of data in the database file is as follows: Start of file 4 byte numeric, magic cookie value identifies this as a data file 4 byte numeric, offset to start of record zero 2 byte numeric, number of fields in each record How to read MAGIC and what mean about the "4 byte numeric"?
Can you use java.io.RandomAccessFile.readInt() and readShort() to read in the db file? I'm asking because sun seemed to be rather specific in their instructions on the format used to read and write from the file: All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII. RandomAccessFile implements DataInput/DataOutput just as DataInputStream/DataOuputStream do, but will using RandomAccessFile fulfill the requirement to use the formats within DataInputStream/DataOuputStream?? Dave
SCJP 1.4, SCJD 1.4, SCWCD 1.3, SCBCD 1.3, IBM Certified Solution Developer -WebSphere Studio V5.0
RandomAccessFile implements DataInput/DataOutput just as DataInputStream/DataOuputStream do, but will using RandomAccessFile fulfill the requirement to use the formats within DataInputStream/DataOuputStream??
As RandomAccessFile implements DataInput/DataOutput, it is format-compatible with both DataInputStream and DataOuputStream. So, I would say that yes, you fulfill the requirement by using it. Notice that your instructions just state that "(...) use the formats of the DataInputStream and DataOutputStream classes", not something like "you must use the DataInputStream and DataOutputStream classes to access the file header". Best, Phil.
Agreed - there is no requirement to use DataInputStream or DataOutputStream. There is merely the information that the format used is the one used by DataInputStream and DataOutputStream. What you do with that information is up to you.