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 Details

    • DefaultFileRegion

      public DefaultFileRegion(FileChannel fileChannel, long position, long count)
      Create a new instance
      Parameters:
      fileChannel - the FileChannel which should be transferred
      position - the position from which the transfer should start
      count - the number of bytes to transfer
    • DefaultFileRegion

      public DefaultFileRegion(File file, long position, long count)
      Create a new instance using the given File. The File will be opened lazily or explicitly via open().
      Parameters:
      file - the File which should be transferred
      position - the position from which the transfer should start
      count - the number of bytes to transfer
  • Method Details