Class DefaultFileRegion

  • All Implemented Interfaces:
    FileRegion
    Direct Known Subclasses:
    FilenameFileRegion

    public class DefaultFileRegion
    extends java.lang.Object
    implements FileRegion
    Manage a File to be sent to a remote host. We keep a track on the current position, and the number of already written bytes.
    Author:
    Apache MINA Project
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultFileRegion​(java.nio.channels.FileChannel channel)
      Creates a new DefaultFileRegion instance
      DefaultFileRegion​(java.nio.channels.FileChannel channel, long position, long remainingBytes)
      Creates a new DefaultFileRegion instance
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.channels.FileChannel getFileChannel()
      The open FileChannel from which data will be read to send to remote host.
      java.lang.String getFilename()
      Provides an absolute filename for the underlying FileChannel.
      long getPosition()
      The current file position from which data will be read.
      long getRemainingBytes()
      The number of bytes remaining to be written from the file to the remote host.
      long getWrittenBytes()
      The total number of bytes already written.
      void update​(long value)
      Updates the current file position based on the specified amount.
      • Methods inherited from class java.lang.Object

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

      • DefaultFileRegion

        public DefaultFileRegion​(java.nio.channels.FileChannel channel)
                          throws java.io.IOException
        Creates a new DefaultFileRegion instance
        Parameters:
        channel - The channel mapped over the file
        Throws:
        java.io.IOException - If we had an IO error
      • DefaultFileRegion

        public DefaultFileRegion​(java.nio.channels.FileChannel channel,
                                 long position,
                                 long remainingBytes)
        Creates a new DefaultFileRegion instance
        Parameters:
        channel - The channel mapped over the file
        position - The position in teh file
        remainingBytes - The remaining bytes
    • Method Detail

      • getWrittenBytes

        public long getWrittenBytes()
        The total number of bytes already written.
        Specified by:
        getWrittenBytes in interface FileRegion
        Returns:
        The total number of bytes already written.
      • getRemainingBytes

        public long getRemainingBytes()
        The number of bytes remaining to be written from the file to the remote host.
        Specified by:
        getRemainingBytes in interface FileRegion
        Returns:
        The number of bytes remaining to be written.
      • getFileChannel

        public java.nio.channels.FileChannel getFileChannel()
        The open FileChannel from which data will be read to send to remote host.
        Specified by:
        getFileChannel in interface FileRegion
        Returns:
        An open FileChannel.
      • getPosition

        public long getPosition()
        The current file position from which data will be read.
        Specified by:
        getPosition in interface FileRegion
        Returns:
        The current file position.
      • getFilename

        public java.lang.String getFilename()
        Provides an absolute filename for the underlying FileChannel.
        Specified by:
        getFilename in interface FileRegion
        Returns:
        the absolute filename, or null if the FileRegion does not know the filename