So I'm trying to read in a very large file using a mapped FileChannel.
The file exceeds 2GB. A snippet of code is:
long fileSize = 0x8FFFFFFFL;
FileChannel fc = new RandomAccessFile("blah.huge", "rw").getChannel();
fc.map(FileChannel.MapMode.READ_WRITE, 0, fileSize);
This throws an error:
Exception in thread "main" java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:789)
FileChannel.map takes a long
as the file size. So does this error make sense? Why would they not provide support for bigger files than that?