public class DefaultFileRegion extends AbstractReferenceCounted implements FileRegion
FileRegion
implementation which transfer data from a FileChannel
.
Be aware that the FileChannel
will be automatically closed once AbstractReferenceCounted.refCnt()
returns
0
.Constructor and Description |
---|
DefaultFileRegion(FileChannel file,
long position,
long count)
Create a new instance
|
Modifier and Type | Method and Description |
---|---|
long |
count()
Returns the number of bytes to transfer.
|
protected void |
deallocate()
Called once
AbstractReferenceCounted.refCnt() is equals 0. |
long |
position()
Returns the offset in the file where the transfer began.
|
long |
transfered()
Return the bytes which was transfered already
|
long |
transferTo(WritableByteChannel target,
long position)
Transfers the content of this file region to the specified channel.
|
refCnt, release, release, retain, retain, setRefCnt
public DefaultFileRegion(FileChannel file, long position, long count)
file
- the FileChannel
which should be transferedposition
- the position from which the transfer should startcount
- the number of bytes to transferpublic long position()
FileRegion
position
in interface FileRegion
public long count()
FileRegion
count
in interface FileRegion
public long transfered()
FileRegion
transfered
in interface FileRegion
public long transferTo(WritableByteChannel target, long position) throws IOException
FileRegion
transferTo
in interface FileRegion
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 FileRegion.position()
th byte and
FileRegion.count()
- 1 will make the last
byte of the region transferred.IOException
protected void deallocate()
AbstractReferenceCounted
AbstractReferenceCounted.refCnt()
is equals 0.deallocate
in class AbstractReferenceCounted
Copyright © 2008–2014 The Netty Project. All rights reserved.