B & S ::Magi cookie during Reading file

Bhavik Patel

Ranch Hand

Posts: 155

posted 10 years ago

hii guys .. i was trying develop sample test proram to read from the file with the following code... first 4 bytes are said to be the magic cookie value(Numeric)and other header part .. It doesnt give me the proper values as i was expecting numeric value for cookie and total fields ..can anyone tell me whats wrong with the follwoing code ...

SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "

Jeroen T Wenting

Ranch Hand

Posts: 1847

posted 10 years ago

They're not stored as Strings.

42

Bhavik Patel

Ranch Hand

Posts: 155

posted 10 years ago

can you please specify in more detail ..how to extract it ??

SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "

Barry Gaunt

Ranch Hand

Posts: 7729

posted 10 years ago

To elaborate a little: when the assignment specification mentions binary (numeric) data it means that you can read it into a variable that is a Javaprimitive type. You can determine that type usually by looking at the length of the field. So if the binary field is 2 bytes it must be a 16 bits Java primitive. Once you have determined the primitive type you can select from the API the appropriate methods to read and write it. [ September 23, 2006: Message edited by: Barry Gaunt ]