• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Question about total num of records ( B & S)

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot guys, that was helpful.
Stef I think I am gonna use your approach, Thanks so much.
 
reply
    Bookmark Topic Watch Topic
  • New Topic