kipedia.org/wiki/Zero-copy">zero-copy file transfer.
Upgrade your JDK / JRE
{@link FileChannel#transferTo(long,long,WritableByteChannel)} has at leastfour known bugs in the old versions of Sun JDK and perhaps its derived ones. Please upgrade your JDK to 1.6.0_18 or later version if you are going to use zero-copy file transfer.
- 5103988 - FileChannel.transferTo() should return -1 for EAGAIN instead throws IOException
- 6253145 - FileChannel.transferTo() on Linux fails when going beyond 2GB boundary
- 6427312 - FileChannel.transferTo() throws IOException "system call interrupted"
- 6470086 - FileChannel.transferTo(2147483647, 1, channel) causes "Value too large" exception
Check your operating system and JDK / JRE
If your operating system (or JDK / JRE) does not support zero-copy file transfer, sending a file with {@link FileRegion} might fail or yield worseperformance. For example, sending a large file doesn't work well in Windows.
Not all transports support it
Currently, the NIO transport is the only transport that supports {@link FileRegion}. Attempting to write a {@link FileRegion} to non-NIO {@link Channel} will triggera {@link ClassCastException} or a similar exception.