Class FilterFileChannel

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.GatheringByteChannel, java.nio.channels.InterruptibleChannel, java.nio.channels.ReadableByteChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.SeekableByteChannel, java.nio.channels.WritableByteChannel

    public class FilterFileChannel
    extends java.nio.channels.FileChannel
    Filters a FileChannel.

    A FilterFileChannel wraps some other channel, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality. The class FilterFileChannel itself simply overrides methods of FileChannel with versions that pass all requests to the wrapped channel. Subclasses of FilterFileChannel may of course override any methods declared or inherited by FilterFileChannel, and may also provide additional fields and methods.

    You construct s simple instance with the channel constructor and more advanced instances through the FilterFileChannel.Builder.

    Since:
    2.22.0
    • Constructor Summary

      Constructors 
      Constructor Description
      FilterFileChannel​(java.nio.channels.FileChannel fileChannel)
      Constructs a new instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      void force​(boolean metaData)  
      static FilterFileChannel.Builder forFilterFileChannel()
      int hashCode()  
      protected void implCloseChannel()  
      java.nio.channels.FileLock lock​(long position, long size, boolean shared)  
      java.nio.MappedByteBuffer map​(java.nio.channels.FileChannel.MapMode mode, long position, long size)  
      long position()  
      java.nio.channels.FileChannel position​(long newPosition)  
      int read​(java.nio.ByteBuffer dst)  
      long read​(java.nio.ByteBuffer[] dsts, int offset, int length)  
      int read​(java.nio.ByteBuffer dst, long position)  
      long size()  
      java.lang.String toString()  
      long transferFrom​(java.nio.channels.ReadableByteChannel src, long position, long count)  
      long transferTo​(long position, long count, java.nio.channels.WritableByteChannel target)  
      java.nio.channels.FileChannel truncate​(long size)  
      java.nio.channels.FileLock tryLock​(long position, long size, boolean shared)  
      java.nio.channels.FileChannel unwrap()
      Unwraps this instance by returning the underlying FileChannel.
      int write​(java.nio.ByteBuffer src)  
      long write​(java.nio.ByteBuffer[] srcs, int offset, int length)  
      int write​(java.nio.ByteBuffer src, long position)  
      • Methods inherited from class java.nio.channels.FileChannel

        lock, open, open, read, tryLock, write
      • Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel

        begin, close, end, isOpen
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.nio.channels.Channel

        isOpen
    • Constructor Detail

      • FilterFileChannel

        public FilterFileChannel​(java.nio.channels.FileChannel fileChannel)
        Constructs a new instance.
        Parameters:
        fileChannel - the file channel to wrap.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • force

        public void force​(boolean metaData)
                   throws java.io.IOException
        Specified by:
        force in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • implCloseChannel

        protected void implCloseChannel()
                                 throws java.io.IOException
        Specified by:
        implCloseChannel in class java.nio.channels.spi.AbstractInterruptibleChannel
        Throws:
        java.io.IOException
      • lock

        public java.nio.channels.FileLock lock​(long position,
                                               long size,
                                               boolean shared)
                                        throws java.io.IOException
        Specified by:
        lock in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • map

        public java.nio.MappedByteBuffer map​(java.nio.channels.FileChannel.MapMode mode,
                                             long position,
                                             long size)
                                      throws java.io.IOException
        Specified by:
        map in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • position

        public long position()
                      throws java.io.IOException
        Specified by:
        position in interface java.nio.channels.SeekableByteChannel
        Specified by:
        position in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • position

        public java.nio.channels.FileChannel position​(long newPosition)
                                               throws java.io.IOException
        Specified by:
        position in interface java.nio.channels.SeekableByteChannel
        Specified by:
        position in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ReadableByteChannel
        Specified by:
        read in interface java.nio.channels.SeekableByteChannel
        Specified by:
        read in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer dst,
                        long position)
                 throws java.io.IOException
        Specified by:
        read in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • read

        public long read​(java.nio.ByteBuffer[] dsts,
                         int offset,
                         int length)
                  throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ScatteringByteChannel
        Specified by:
        read in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • size

        public long size()
                  throws java.io.IOException
        Specified by:
        size in interface java.nio.channels.SeekableByteChannel
        Specified by:
        size in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • transferFrom

        public long transferFrom​(java.nio.channels.ReadableByteChannel src,
                                 long position,
                                 long count)
                          throws java.io.IOException
        Specified by:
        transferFrom in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • transferTo

        public long transferTo​(long position,
                               long count,
                               java.nio.channels.WritableByteChannel target)
                        throws java.io.IOException
        Specified by:
        transferTo in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • truncate

        public java.nio.channels.FileChannel truncate​(long size)
                                               throws java.io.IOException
        Specified by:
        truncate in interface java.nio.channels.SeekableByteChannel
        Specified by:
        truncate in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • tryLock

        public java.nio.channels.FileLock tryLock​(long position,
                                                  long size,
                                                  boolean shared)
                                           throws java.io.IOException
        Specified by:
        tryLock in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • unwrap

        public java.nio.channels.FileChannel unwrap()
        Unwraps this instance by returning the underlying FileChannel.

        Use with caution.

        Returns:
        the underlying FileChannel.
      • write

        public int write​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Specified by:
        write in interface java.nio.channels.SeekableByteChannel
        Specified by:
        write in interface java.nio.channels.WritableByteChannel
        Specified by:
        write in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • write

        public int write​(java.nio.ByteBuffer src,
                         long position)
                  throws java.io.IOException
        Specified by:
        write in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException
      • write

        public long write​(java.nio.ByteBuffer[] srcs,
                          int offset,
                          int length)
                   throws java.io.IOException
        Specified by:
        write in interface java.nio.channels.GatheringByteChannel
        Specified by:
        write in class java.nio.channels.FileChannel
        Throws:
        java.io.IOException