title: What is the cause of BufferOverflowException?
body: <p>The exception stack is  <br></p>
  
  <pre><code>java.nio.BufferOverflowException
       at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:327)
       at java.nio.ByteBuffer.put(ByteBuffer.java:813)
              mappedByteBuffer.put(bytes);
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>randomAccessFile = new RandomAccessFile(file, "rw");
  fileChannel = randomAccessFile.getChannel();
  mappedByteBuffer = fileChannel.map(MapMode.READ_WRITE, 0, file.length());
  </code></pre>
  
  <p>and call <code>mappedByteBuffer.put(bytes);</code></p>
  
  <p>What is the cause  <code>mappedByteBuffer.put(bytes)</code> throws BufferOverflowException
  <br>
  How to find the cause ?</p>