my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question about total num of records ( B & S) 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 "Question about total num of records ( B & S)" Watch "Question about total num of records ( B & S)" New topic
Author

Question about total num of records ( B & S)

Jay Ashar
Ranch Hand

Joined: Oct 13, 2002
Posts: 208
Hello All,
I am working on getting my SCJD, so far this forum has been of great help, just by reading posts from this forum I was able to develop my project from start to bottom. I have been silent reader of this forum but I have a question today.
How can I get total number of records in my data file. My data file doesnt have any flag which tells me total number of records. Currently I have it in suncertify.properties file and when I create a record I read it from prop file add one to it and store it back to property file. Is this all rite?? Just wanted to get some opinions.

Thanks in advance.


SCJP 1.4<br />SCWCD 1.3
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
Why is it necessary to know the total number of records? One technique might be to keep looping while the random access file pointer is less than the length of the file.
Stef Widmer
Greenhorn

Joined: Jun 16, 2004
Posts: 17
Hi Mike
I'm working on the "Bodgitt and Scarper" assigment, but I belive you could use my aproach as well.
I simply substract the data description section from the total db file length and divide the rest through the length of one record. This givs me the total number of records. This looks like this:

totRecNum = (int) (this.length() - startOfDataSection) / recDesc.getRecordLen();

Cheers Stef
Jay Ashar
Ranch Hand

Joined: Oct 13, 2002
Posts: 208
Thanks a lot guys, that was helpful.
Stef I think I am gonna use your approach, Thanks so much.
 
Consider Paul's rocket mass heater.
 
subject: Question about total num of records ( B & S)