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 B & S ::Magi cookie during Reading file 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 "B & S ::Magi cookie during Reading file" Watch "B & S ::Magi cookie during Reading file" New topic
Author

B & S ::Magi cookie during Reading file

Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
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

Joined: Apr 21, 2006
Posts: 1847
They're not stored as Strings.


42
Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
can you please specify in more detail ..how to extract it ??
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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 Java primitive 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 ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329

[ September 23, 2006: Message edited by: Ken Boyd ]

SCJP, SCWCD, SCBCD, SCJD, BB Java2 and JSP1.1
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Excellent Ken, but not in the spirit of the SCJD certification somehow.
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
sorry about that..I knew I shouldn't do it but sometime people ask for everything
 
jQuery in Action, 2nd edition
 
subject: B & S ::Magi cookie during Reading file
 
Similar Threads
Interpretation of data file format
URLy 1.1.2 - Reading the DB
NX:Reading and Writting to DB file - totally lost!!!!!
DB file reading problem
URLyBird: Read data file