Class DefaultFileRegion

    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultFileRegion​(java.nio.channels.FileChannel file, long position, long count)  
      DefaultFileRegion​(java.nio.channels.FileChannel file, long position, long count, boolean releaseAfterTransfer)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • file

        private final java.nio.channels.FileChannel file
      • position

        private final long position
      • count

        private final long count
      • releaseAfterTransfer

        private final boolean releaseAfterTransfer
    • Constructor Detail

      • DefaultFileRegion

        public DefaultFileRegion​(java.nio.channels.FileChannel file,
                                 long position,
                                 long count)
      • DefaultFileRegion

        public DefaultFileRegion​(java.nio.channels.FileChannel file,
                                 long position,
                                 long count,
                                 boolean releaseAfterTransfer)
    • Method Detail

      • getPosition

        public long getPosition()
        Description copied from interface: FileRegion
        Returns the offset in the file where the transfer began.
        Specified by:
        getPosition in interface FileRegion
      • getCount

        public long getCount()
        Description copied from interface: FileRegion
        Returns the number of bytes to transfer.
        Specified by:
        getCount in interface FileRegion
      • releaseAfterTransfer

        public boolean releaseAfterTransfer()
      • transferTo

        public long transferTo​(java.nio.channels.WritableByteChannel target,
                               long position)
                        throws java.io.IOException
        Description copied from interface: FileRegion
        Transfers the content of this file region to the specified channel.
        Specified by:
        transferTo in interface FileRegion
        Parameters:
        target - the destination of the transfer
        position - 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.
        Throws:
        java.io.IOException