How to read large files with MappedByteBuffer?

346 views Asked by At

I want to read a 30GB file using MappedByteBuffer.

try (FileChannel sourceChannel = new RandomAccessFile("sample.csv", "r").getChannel()) {
    MappedByteBuffer buf = sourceChannel.map(FileChannel.MapMode.READ_ONLY, 0, sourceChannel.size());
}

Problem:

java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE
    at java.base/sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:941)

What could I do here?

0

There are 0 answers