Hi all I have been a bit confused on how to go by implementing the read() method. Since it accepts an Integer, my immediate instinct is that it would use the value supplied and jump to a particular section(That is after all the schema section and header section has been skipped)!I would like it if i could get a pseudo-code of some kind!
Well, you are basically correct. So try to write a formula for getting to the n-th record, n >= 0. Let p(n) be the file pointer position of the record you want to find. Let o be the offset to the first data record, r be the record length (including its delete flag). What's p(n)?
You may have to adjust that for your own particular file schema. [ December 03, 2005: Message edited by: Barry Gaunt ]
Hi Thanks i was able to solve the above quoted problem on the same day! Now the problem i face s this: I intend to use a cache(An arraylist), that would have the records on the data file. My algorithm would involve the constructor of my data class read the whole records of the datafile unto an arrayList(private static: so that only one instance is available if client requests for the data file). My question is this: Do i allow the read() method read from this cache instead of the actual file?My second question is: Is it ok to have the constructor of data.java read all the record once it is invoked?Thanks!
Joined: Jun 23, 2004
Hi My other question is: Do i sync on my cache cause i figured, a client might be trying to update, a deleted record!In any case, i would luv a push in the right direction! Thanks!