aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Buffer & read method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Buffer & read method" Watch "Buffer & read method" New topic
Author

Buffer & read method

Omar Kalaldeh
Ranch Hand

Joined: Jun 08, 2004
Posts: 58
Hi All,

In me Design I decide to use buffering, but I have a problem with DB interface, it says in the read method comment



// Reads a record from the file. Returns an array where each
// element is a record value.



Now, in read method must I read the records only from data file, and it�s not acceptable to read it from the buffer, or it is all right if I read them from my buffer.

If it the first case, then I must put another public method called readFromBuffer(), witch make Data class a little bit weird and confusing .

Or should I forget about all about buffer, and stay in safe line.

In suggestion will be helpful .


Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
Marcus Beale
Ranch Hand

Joined: Apr 13, 2004
Posts: 33
If you use a RandomAccessFile Object to read the database file, I believe it does a lot of buffering for you. So I don't think you need to worry about buffering directly.

You must be careful with buffering however when dealing with multiple threads. A lot of people do away with the buffering in the RandomAccessFile by openening in the "rwd" mode. I don't believe you need to do this unless you have more than on RandomAccessFile object (some people do have more than one for some strange reason).

,Marcus
Omar Kalaldeh
Ranch Hand

Joined: Jun 08, 2004
Posts: 58
Hi Marcus,

Thank you for your suggestions.

But throw using buffering I may simplified some implementations issues such as searching, so I still need to know if implementing read method to read from buffer is a valid choice.

Again thank you for your response .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Buffer & read method
 
Similar Threads
LIVE_RECORD
Reading the record from the database
Synchronization of public methods in DVDDatabase
nx: All of URLy Bird 1.1.3 read/write lock(2)
NX: URLYBird / my approach of the reading problem