I've created a java.nio.MappedByteBuffer
around a java.io.RandomAccessFile
(a file which is only 54 KB in size). The resulting MappedByteBuffer
has a "capacity" and "limit" of around 12 KB, so when I try to invoke mybytebuffer.get(i > 13044)
or mybytebuffer.put(i > 13044, value)
it throws an InvalidIndexException
.
All of this behavior is documented in Sun's official javadocs. My question is how I can use java.nio ByteBuffers
to read or write anywhere in the file (I need random access). I can't seem to find an example or documentation of Java NIO that illustrates non-sequential access.