所以我试图读取一个非常大的文件使用映射的FileChannel。Java可能FileChannel.map错误
该文件超过2GB。一个代码片段是:
long fileSize = 0x8FFFFFFFL;
FileChannel fc = new RandomAccessFile("blah.huge", "rw").getChannel();
fc.map(FileChannel.MapMode.READ_WRITE, 0, fileSize);
这引发错误:
Exception in thread "main" java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:789)
FileChannel.map需要long
作为文件大小。那么这个错误是否有意义?为什么他们不支持比这更大的文件?
按照记录工作,downvote。 – EJP
+1:记录极限并不意味着它是有道理的。 –