I read a file into a MappedByteBuffer
:
MappedByteBuffer buffer = FileChannel.open(file, StandardOpenOption.READ)
.map(FileChannel.MapMode.READ_ONLY, 0, Files.size(file))
.load();
And write it to an OutputStream
:
Channels.newChannel(getOutputStream())
.write(buffer);
However, I can only do this one, presumably because the ByteBuffer
"current location" is at the end of the buffer.
So what is the recommended way to handle the fact I wish to have multiple threads use this memory mapped file?