What is the cause of BufferOverflowException?

Viewed 44752

The exception stack is

java.nio.BufferOverflowException
     at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:327)
     at java.nio.ByteBuffer.put(ByteBuffer.java:813)
            mappedByteBuffer.put(bytes);

The code:

randomAccessFile = new RandomAccessFile(file, "rw");
fileChannel = randomAccessFile.getChannel();
mappedByteBuffer = fileChannel.map(MapMode.READ_WRITE, 0, file.length());

and call mappedByteBuffer.put(bytes);

What is the cause mappedByteBuffer.put(bytes) throws BufferOverflowException
How to find the cause ?

2 Answers
Related