public interface FileRegion extends ReferenceCounted
Channel
which supports
zero-copy file transfer.
FileChannel.transferTo(long, long, WritableByteChannel)
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.
FileRegion
might fail or yield worse
performance. For example, sending a large file doesn't work well in Windows.
限定符和类型 | 方法和说明 |
---|---|
long |
count()
Returns the number of bytes to transfer.
|
long |
position()
Returns the offset in the file where the transfer began.
|
long |
transfered()
Return the bytes which was transfered already
|
long |
transferTo(java.nio.channels.WritableByteChannel target,
long position)
Transfers the content of this file region to the specified channel.
|
long position()
long transfered()
long count()
long transferTo(java.nio.channels.WritableByteChannel target, long position) throws java.io.IOException
target
- the destination of the transferposition
- the relative offset of the file where the transfer
begins from. For example, 0 will make the
transfer start from position()
th byte and
count()
- 1 will make the last
byte of the region transferred.java.io.IOException