public class DefaultFileRegion extends io.netty.util.AbstractReferenceCounted implements FileRegion
FileRegion implementation which transfer data from a FileChannel or File.
Be aware that the FileChannel will be automatically closed once AbstractReferenceCounted.refCnt() returns
0.| Constructor and Description |
|---|
DefaultFileRegion(FileChannel fileChannel,
long position,
long count)
Create a new instance
|
DefaultFileRegion(File file,
long position,
long count)
Create a new instance using the given
File. |
| Modifier and Type | Method and Description |
|---|---|
long |
count()
Returns the number of bytes to transfer.
|
protected void |
deallocate() |
boolean |
isOpen()
Returns
true if the FileRegion has a open file-descriptor |
void |
open()
Explicitly open the underlying file-descriptor if not done yet.
|
long |
position()
Returns the offset in the file where the transfer began.
|
FileRegion |
retain() |
FileRegion |
retain(int increment) |
FileRegion |
touch() |
FileRegion |
touch(Object hint) |
long |
transfered()
Deprecated.
|
long |
transferred()
Returns the bytes which was transferred already.
|
long |
transferTo(WritableByteChannel target,
long position)
Transfers the content of this file region to the specified channel.
|
refCnt, release, release, setRefCntpublic DefaultFileRegion(FileChannel fileChannel, long position, long count)
fileChannel - the FileChannel which should be transferredposition - the position from which the transfer should startcount - the number of bytes to transferpublic DefaultFileRegion(File file, long position, long count)
File. The File will be opened lazily or
explicitly via open().file - the File which should be transferredposition - the position from which the transfer should startcount - the number of bytes to transferpublic boolean isOpen()
true if the FileRegion has a open file-descriptorpublic void open()
throws IOException
IOExceptionpublic long position()
FileRegionposition in interface FileRegionpublic long count()
FileRegioncount in interface FileRegion@Deprecated public long transfered()
FileRegiontransfered in interface FileRegionpublic long transferred()
FileRegiontransferred in interface FileRegionpublic long transferTo(WritableByteChannel target, long position) throws 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.position()th byte and
FileRegion.count() - 1 will make the last
byte of the region transferred.IOExceptionprotected void deallocate()
deallocate in class io.netty.util.AbstractReferenceCountedpublic FileRegion retain()
retain in interface FileRegionretain in interface io.netty.util.ReferenceCountedretain in class io.netty.util.AbstractReferenceCountedpublic FileRegion retain(int increment)
retain in interface FileRegionretain in interface io.netty.util.ReferenceCountedretain in class io.netty.util.AbstractReferenceCountedpublic FileRegion touch()
touch in interface FileRegiontouch in interface io.netty.util.ReferenceCountedtouch in class io.netty.util.AbstractReferenceCountedpublic FileRegion touch(Object hint)
touch in interface FileRegiontouch in interface io.netty.util.ReferenceCountedCopyright © 2008–2025 The Netty Project. All rights reserved.