Meaningless Drivel is fun!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to decide header length from data 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 "How to decide header length from data file ?" Watch "How to decide header length from data file ?" New topic

How to decide header length from data file ?

Tien Fu Liu

Joined: Jun 22, 2003
Posts: 8
My question is based on the instruction as follows, how do you decide the header length?

Can I say the header length is simply as 4+4+2=10?

Thanks very much!

Start of file
4 byte numeric - magic cookie
4 byte numeric - length of the record
2 byte numeric - number of fields in each record

Schema Description
2 byte numeric - length in bytes of field name
n bytes - field name
2 bytes numeric - field length in bytes
repeat the above for every field in the record
Data Section
1 byte delete flag - 00 valid record, 0xFF deleted record
Record contains fields in the order specified, no seperators bet fields, each field is fixed length at maximum specified in schema information

End of file
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
It depends what you consider to be the "header". I use the term "header" for the portion of the file starting at the beginning of the file, up to the start of the first record. That is, the header includes the schema description section.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: How to decide header length from data file ?
It's not a secret anymore!