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?
- Instantiate two
RandomAccessFile
instances one to read and the other to write. Of course these would be tightly synchronized. - 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.