This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have tried that and I am a little confused when the result is:
Number of fields in each record: 1311 (if I remember correctly, I dont have the IDE up and running at the moment)
This is my intruction:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
1 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
1 byte numeric, field length in bytes
end of repeating block
Repeat to end of file:
1 byte flag. 00 implies valid record, 0xFF implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information
The file is not a plain text file, hence the squares and funny characters you'll see when opening it with NotePad for example. You could use a HexEditor or just use Roberto's file reader. You can also write your own little database file reader, based on the instructions you got (using a RandomAccessFile or a DataInputStream).
This was my own file reader (of course you'll have to make changes according to your instructions:
Number of fields in each record: 1311
I think that is wrong, because the normal number of fields would be less than 10. Maybe it could be the value of your magic cookie.
 changed code snippet according to structure database file
Thanks very much for taking the time to help me Roel!
Not a problem at all! One year ago I was in the same position as you: starting with SCJD and I was glad people took the time to help me with my questions, so just giving something back to the community.
At a first glance to the description of your database file your file only has magic cookie and number of fields. My database file has magic cookie, length of a record and number of fields. So try to uncomment lines 12 and 13, and have another shot.
Roberto Perillo wrote:You couldn't read it, even with the DBFileReader tool?
If the structure of his database file (supplied in one of his previous posts) is consistent with the one from his instructions, it is completely normal he can't read it with your tool, because it seems his database file doesn't have a recordLength (between magicCookie and numberOfFields)
@Peter: i changed my snippet of code to read the database file according to the description you provided in 1 of your earlier posts. Can you give it a try and see of you get any meaningful output?
Roel De Nijs wrote:If the structure of his database file (supplied in one of his previous posts) is consistent with the one from his instructions, it is completely normal he can't read it with your tool
Obviously. The only thing different in the format of his schema is that the record length is not informed, so he should be able to read it with DBFileReader with small modifications in the code.
Joined: Jan 14, 2010
Thanks Roel that made the trick!
Now I know that there are nothing wrong with the file. (I didnt think it was but....) Now I am gonna studdy this to fully understand it.
Roberto Perillo wrote:he should be able to read it with DBFileReader with small modifications in the code.
Your DBFileReader is indeed a great tool and these small modifications should make it possible to read his database file:And put every line about recordLength (96, 100, 104, 110, 111) in comment (or just delete them). Now he has 2 programs to read his database file
another important note: remember to be sure to have an original copy of your database file, because you have to provide the original copy when submitting (and it is also very useful when you corrupted your file while modifying it)