Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using RandomAccessFile

 
Yu Sun
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

When we use RandomAccessFile to read or write to the database file, can we simply pass the initial header information in the file and go to the data section directly.

For example, databaseFile.seek(70). And then iterate each record. The value of the location is precalculated.

Thanks.

Yu
 
David Byron
Rancher
Posts: 175
Clojure Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You can either read the header info dynamically (as Roel did) or hard code the values (as Roberto did). (I hope I remembered that correctly!)

Either way, one benefit of the RandomAccessFile is that you can bypass what isn't interesting and go directly to the records. Going to a given record by its number will prove quite convenient.
 
Yu Sun
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David. I will go the simple way (as Roberto did)
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yu Sun wrote:I will go the simple way (as Roberto did)


You are a smart guy, champion!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Byron wrote:(I hope I remembered that correctly!)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic