aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Calculating OffSet 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 "Calculating OffSet" Watch "Calculating OffSet" New topic
Author

Calculating OffSet

Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
Hello Guys, I am confuse about calculating Offset Values.

For the first record.. it should be

the header ... but for the 2nd and next...

do use

1) headersize + (a record size * currentRecordNo) + deleteflag(1)

or

2) headersize + (a record size * (currentRecordNo)) + currentRecordNo;

it seems the 2nd way works.. I don't understand why must i add the current record count and not + 1 for delete flag.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5543
    
  13

Maybe it is just working because your deleted flag is 1. If it was 2 I guess your 2nd formula would not work at all.

I would expect something like: headerSize + ((record length + deleted flag) * recNo)


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
same here.. I would also expect that + 1 for delete flag(but it didn't work all the words are jumble up)... BUT the 2nd formula works!!! I don't know why.. can some guru explain to me~??~
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5543
    
  13

Please notice the difference in my formula against your 1st formula! They give complete different results!
Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
Roel De Nijs wrote:Please notice the difference in my formula against your 1st formula! They give complete different results!


oh!! pardon me, I haven't been sleeping much for days.. and still stuck @ database layer..

Thanks once again
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

I'd suggest opening the file with a Hex Editor and starting comparing the schema to the file contents. Then everything will be clear. This thread here should help you to understand the schema and read the data file.


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calculating OffSet