public class DefaultFileRegion extends java.lang.Object implements FileRegion
| Modifier and Type | Field and Description |
|---|---|
private long |
count |
private java.nio.channels.FileChannel |
file |
private static InternalLogger |
logger |
private long |
position |
private boolean |
releaseAfterTransfer |
| Constructor and Description |
|---|
DefaultFileRegion(java.nio.channels.FileChannel file,
long position,
long count) |
DefaultFileRegion(java.nio.channels.FileChannel file,
long position,
long count,
boolean releaseAfterTransfer) |
| Modifier and Type | Method and Description |
|---|---|
long |
getCount()
Returns the number of bytes to transfer.
|
long |
getPosition()
Returns the offset in the file where the transfer began.
|
boolean |
releaseAfterTransfer() |
void |
releaseExternalResources()
Releases the external resources that this object depends on.
|
long |
transferTo(java.nio.channels.WritableByteChannel target,
long position)
Transfers the content of this file region to the specified channel.
|
private static final InternalLogger logger
private final java.nio.channels.FileChannel file
private final long position
private final long count
private final boolean releaseAfterTransfer
public DefaultFileRegion(java.nio.channels.FileChannel file,
long position,
long count)
public DefaultFileRegion(java.nio.channels.FileChannel file,
long position,
long count,
boolean releaseAfterTransfer)
public long getPosition()
FileRegiongetPosition in interface FileRegionpublic long getCount()
FileRegiongetCount in interface FileRegionpublic boolean releaseAfterTransfer()
public long transferTo(java.nio.channels.WritableByteChannel target,
long position)
throws java.io.IOException
FileRegiontransferTo in interface FileRegiontarget - 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 FileRegion.getPosition()th byte and
FileRegion.getCount() - 1 will make the last
byte of the region transferred.java.io.IOExceptionpublic void releaseExternalResources()
ExternalResourceReleasablereleaseExternalResources in interface ExternalResourceReleasable