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 Magic cookie and deleted record flag 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 "Magic cookie and deleted record flag" Watch "Magic cookie and deleted record flag" New topic

Magic cookie and deleted record flag

Payal Shah
Ranch Hand

Joined: Jul 10, 2006
Posts: 67

1) Magic Cookie:
I am hardcoding the magic cookie value to 259 since the give data file has that value. Everytime I read the header file, I am checking that cook is 259. If the value is not 259, I throw new IOException().
Is that right?

2) 1 byte flag. 00 implies valid record, 0xFF implies deleted record.
When I read the file, that field has 0 value not 00.
what is 0xFF? Is it a hexadecimal number? Am a storing hex when the record gets deleted.
Right now, I have flag as type byte in my data object. I am not sure if I just make this field string and store "0xff" as a string value.

Thank you.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
For number 1, you are correct. Magic cookie is for determining that the file is the correct file.

For number 2, if you want to know the value of 0xFF, just use the System.out.println(0xFF). I tried in my calculator, the value is 255. You can try in your own calculator.

for each record n the database you can try this :

Remember, if you can read all the data in the database scheme, it means you already have a good start. Reading all the database scheme was my first step. I shared my experience in here :

Good Luck !!!

Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)
Payal Shah
Ranch Hand

Joined: Jul 10, 2006
Posts: 67
Thank you :-)
I agree. Here's the link:
subject: Magic cookie and deleted record flag
It's not a secret anymore!