File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes magic cookie and 0x800 flag doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "magic cookie and 0x800 flag doubt" Watch "magic cookie and 0x800 flag doubt" New topic
Author

magic cookie and 0x800 flag doubt

Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Hi guys, my name is Jeffry. Today I download the URLyBird 1.3.2 project assignment and I already figure out how to read the contents of the file provided with the assignment.

When my program read 4 bytes for magic cookies, it show strange number that doesn't make sense to me, while the other bytes such as offset, number of fields, etc show the correct number. What is the purpose of magic cookie?

I also read a part in my assignment that shows like this:

Repeat to end of file:
2 byte flag. 00 implies valid record, 0x8000 implies deleted record


What is "0x8000" and "00" ? Is that a String or number or what ?


Thanks


Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on URLyBird 1.3.2)
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi Jeffry,

I don't really know this assignment but 0x is used as a prefix to numbers in hexadecimal notation. So you have the hexadecimal numbers 0000 (= 0 decimal) and 8000 (= 32768 decimal). In your case it seems that the corresponding decimal value isn't that important. The two bytes (4 digits in hex correspond to 2 bytes) are probably just used to signal the current state of these records.

Marco

[ June 28, 2008: Message edited by: Marco Ehrentreich ]
[ June 28, 2008: Message edited by: Marco Ehrentreich ]
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
What about magic cookie? I tried read the 0x8000 as a short (2 bytes) and it prints -32768. Which one is right? look at the code




Thanks Friends

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

The concrete decimal interpretation of the binary value depends on the number of bits the type of a variable can hold and if the type is a signed or un-signed type. You can find more information on this here.

Marco
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
thanks friends. Did you already SCJD?
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

No, I don't have any certifications yet. But I'm thinking about doing the SCJD exam at the end of year... Unfortunately I don't find enough time for this at the moment.

Anyway I wish you good luck for your exam

Marco
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Ok, thanks. IF you don't have much time to SCJD then consider to take SCWCD.


Thanks

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi Jeffry,

I have less experience in Java web development, so I think I would most probably take the SCJP and SCJD exams first. But just out of curiosity do you really think the SCWCD exam is easier to prepare for?

Marco
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Yes, I think SCWCD is easier than SCJD because it only involving theory based exam.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: magic cookie and 0x800 flag doubt