File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DB header format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DB header format" Watch "DB header format" New topic

DB header format

Bert Ley

Joined: May 09, 2004
Posts: 3

I was wondering could somebody help me out or point me in the right direction. I've just started the SCJD. I was able to extract the first 3 values from the .db file but when I looked at the layout of the information in the .db file it appears as shown below(a partial screen dump from command prompt),


♦name location @ ♂specialties @ ♦size ♠ ♦rate ♣owner

The different symbols stand for the 2 byte numerics wrapping the field names but it appears that the numerics are missing from after the 'name' field and before the 'location' field. Is this a problem with ht efile sent to me by SUN or should those valuse not be there. Any help is really appreciated.
Laura Williamson
Ranch Hand

Joined: Apr 28, 2004
Posts: 44
yes i have beenhere. use readByte, readShort, etc
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Aah....That name sounds too familiar!...
Welcome to the ranch and to the forum!(at last I get the lucky chance to welcome somebody in this forum )

The db file is a binary file, so it is different. It also contains a lot of non-printable ascii characters.You could use a Hex editor to read the data or write a small program to read the file contents.
As Laura suggested, use Java IO API to read/write the file contents. I am using RandomAccessFile for my assignment.You should also go thru your Data File Format section in your instructions document.That explains the data schema of the supplied database file.
Bert Ley

Joined: May 09, 2004
Posts: 3
I was using readShort and readInt to get the first values and they worked fine. But then when I printed out the file values in DOS there were a few missing but then I used the Hex editor and they seem to be there alright. cheers for the help.

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi Bert,

Welcome to JavaRanch.

We don't have many rules here, but one we do have is the JavaRanch Official Policy On Displayed Names, which requires your displayed name to show both a first and a last name.

Could you please change your displayed name to meet this policy? You can change it here.

Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
james airey
Ranch Hand

Joined: Dec 15, 2003
Posts: 41
i think the numerics in the db file are confusing.
if i remember correctly, some of them are genuinely numbers in hex form, and some of them go via a text format.

eg, the length of a field is a hex number, and needs to be read as such.
however the capacity of a room is a text number, so needs to be read as an int, and then cast as a char, or something like that.

i could be wrong though ...
I agree. Here's the link:
subject: DB header format
It's not a secret anymore!