Class DefaultFileRegion

java.lang.Object
io.netty.util.AbstractReferenceCounted
io.netty.channel.DefaultFileRegion
All Implemented Interfaces:
FileRegion, ReferenceCounted

public class DefaultFileRegion extends AbstractReferenceCounted implements FileRegion
Default 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 Summary

    Constructors
    Constructor
    Description
    DefaultFileRegion(File file, long position, long count)
    Create a new instance using the given File.
    DefaultFileRegion(FileChannel fileChannel, long position, long count)
    Create a new instance
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of bytes to transfer.
    protected void
    Called once AbstractReferenceCounted.refCnt() is equals 0.
    boolean
    Returns true if the FileRegion has a open file-descriptor
    void
    Explicitly open the underlying file-descriptor if not done yet.
    long
    Returns the offset in the file where the transfer began.
    Increases the reference count by 1.
    retain(int increment)
    Increases the reference count by the specified increment.
    Records the current access location of this object for debugging purposes.
    touch(Object hint)
    Records the current access location of this object with an additional arbitrary information for debugging purposes.
    long
    Deprecated.
    long
    Returns the bytes which was transferred already.
    long
    transferTo(WritableByteChannel target, long position)
    Transfers the content of this file region to the specified channel.

    Methods inherited from class AbstractReferenceCounted

    refCnt, release, release, setRefCnt
    Modifier and Type
    Method
    Description
    int
    Returns the reference count of this object.
    boolean
    Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
    boolean
    release(int decrement)
    Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
    protected final void
    setRefCnt(int refCnt)
    An unsafe operation intended for use by a subclass that sets the reference count of the buffer directly

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait