• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB header format

 
Bert Ley
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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.
thanks.
 
Laura Williamson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i have beenhere. use readByte, readShort, etc
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bert,
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
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Bert
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11866
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
james airey
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic