2

I'm using a RandomAccessFile to rw data to it constantly. The size of the file can range from 5MB up to 200MB. This file is used as a circular buffer.

My main concern is the constant seek before a read and write.

What happens after seek? Does part of the file data get buffered right away into memory? Does it even do anything after a seek?

I want to understand how it works and how I could improve the performance of using the RandomAccessFile to read write at different positions. I just feel the constant seek is possibly using too many resources?

Possible solution to avoid constant seek?

  1. Instantiate two RandomAccessFile instances one to read and the other to write. Of course these would be tightly synchronized.
  2. Use two FileChannels. Not even sure how I could prevent the pointer from moving when I need to read the tail of my buffer or the head of the buffer.
Jona
  • 13,325
  • 15
  • 86
  • 129
  • http://stackoverflow.com/questions/5614206/buffered-randomaccessfile-java might help – edthethird Aug 07 '12 at 00:54
  • Thanks for the link... Let me update my question with a bit more stuff I'm figuring out thanks to that post... – Jona Aug 07 '12 at 01:14

0 Answers0