The exception stack is
java.nio.BufferOverflowException at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:327) at java.nio.ByteBuffer.put(By
Supposedly because your byte array is bigger then the buffer.
put(byte [] bytes)
I'd go by checking your file.length() and make sure that your memory buffer can actually be written.