异常堆栈是
java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:327)
at java.nio.ByteBuffer.put(ByteBuffer.java:813)
mappedByteBuffer.put(bytes);
代码:
randomAccessFile = new RandomAccessFile(file, "rw");
fileChannel = randomAccessFile.getChannel();
mappedByteBuffer = fileChannel.map(MapMode.READ_WRITE, 0, file.length());
当调用mappedByteBuffer.put(bytes)
时,为什么会抛出BufferOverflowException异常?
如何找到原因?
bytes
的声明吗? - Mehmet Sedat Güngörbytes
的大小怎么样? - tkroman