G
gwlucas
I have an application where I need to read data from random posiitions
within file. In this case performance is VERY important. The problem I
am running into is that the RandomAccessFile class appears to have
serious performance issues. Based on a bit of experimentation, I
suspect that it doesn't implement any kind of intrinsic buffering.
Anyway, I can think of five or six ways of working around this
problem, but I can't believe that there isn't a standard solution. As
a rule, I like to stick to "recognized practices of the community"
even when it would be more fun to "roll my own." So... is there a
canonical solution? Would somebody be able to point me in the right
direction?
Background
I have a file containing blocks of data that need to be accessed at
random. I never know which block I am going to need to read next but,
within each block, the data is read in sequence. The pattern of access
is somewhat similar to an old fashioned ISAM file. Thus I would like
to set the file pointer to the beginning of the block, read some
integers, read some doubles, etc, all in sequence. Later, I would jump
to another file position and do the same. Normally, I would accomplish
these sequential reads with a BufferedInputStream. But since I do have
the random access component, that doesn't seem to be an option
(apparently, you cant wrap a BufferedInputStream around a random
access file).
Thanks in advance for your help.
Gary
within file. In this case performance is VERY important. The problem I
am running into is that the RandomAccessFile class appears to have
serious performance issues. Based on a bit of experimentation, I
suspect that it doesn't implement any kind of intrinsic buffering.
Anyway, I can think of five or six ways of working around this
problem, but I can't believe that there isn't a standard solution. As
a rule, I like to stick to "recognized practices of the community"
even when it would be more fun to "roll my own." So... is there a
canonical solution? Would somebody be able to point me in the right
direction?
Background
I have a file containing blocks of data that need to be accessed at
random. I never know which block I am going to need to read next but,
within each block, the data is read in sequence. The pattern of access
is somewhat similar to an old fashioned ISAM file. Thus I would like
to set the file pointer to the beginning of the block, read some
integers, read some doubles, etc, all in sequence. Later, I would jump
to another file position and do the same. Normally, I would accomplish
these sequential reads with a BufferedInputStream. But since I do have
the random access component, that doesn't seem to be an option
(apparently, you cant wrap a BufferedInputStream around a random
access file).
Thanks in advance for your help.
Gary