我正在尝试将随机访问文件映射到内存,然后想要附加一些数据。
MappedByteBuffer buffer = file.getChannel().map(MapMode.READ_WRITE, 0, size);
如果 size > file.length
会发生什么?
最佳答案
这个问题的答案在 Javadoc 中:
The behavior of this method when the requested region is not completely contained within this channel's file is unspecified.
关于java - 如果在执行 FileChannel.map() 时 MappedByteBuffer 的大小大于文件长度,会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11271546/