java.nio.channels.FileChannel.transferTo has at least four 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.
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 FileRegion might fail or yield worse performance. For example, sending a large file doesn't work well in Windows.
Returns the offset in the file where the transfer began.
Returns the offset in the file where the transfer began.
Attributes
def transferTo(target: WritableByteChannel, position: Long): Long
Transfers the content of this file region to the specified channel.
Transfers the content of this file region to the specified channel.
Value parameters
position
the relative offset of the file where the transfer begins from. For example, 0 will make the transfer start from positionth byte and count - 1 will make the last byte of the region transferred.