I am doing the following to read the db file. Below is my schema sepc. ******************************************* 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
Schema description section. Repeated for each field in a record: 2 byte numeric, length in bytes of field name n bytes (defined by previous entry), field name 2 byte numeric, field length in bytes end of repeating block *******************************************
raf.readShort()
The problem I have is when I try to print the "length in bytes of field name ", it prints 0. without this I can not make sense of the contents of the record. However, when I execute the last print statement, it prints the entire record correctly. Am I missing something ? Any input is appreciated.
Furthermore, if you are attempting to read the schema (as your code suggests), you should surely not seek to the first record. The schema data is located before all the record data and immediately behind the field that contains the offset to the first record.
Thus, just omit the seek call and you'll probably be fine.
Alternatively, if you don't want to read the schema, but instead hardcode the field sizes in your code, then keep the seek, but don't expect the first short to be the field size; field sizes are only specified once in the schema and are not repeated in the individual records. As Clemens already indicated, the first short in the record will probably be the delete status flag. (The database formats vary between assignments, so I cannot tell for sure without seeing your instructions.)
Frans.
SCJP 1.4, SCJD
Vrinda Werdel
Ranch Hand
Joined: Jan 03, 2004
Posts: 75
posted
0
Clemens and Frans,
Thanks for your inputs. I am clearly able to visualize the file structure now. Your responses definitely hepled me move fwd.