Package org.apache.commons.io.channels

# Class FilterFileChannel

java.lang.Object
java.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.FileChannel
org.apache.commons.io.channels.FilterFileChannel

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `ByteChannel`, `Channel`, `GatheringByteChannel`, `InterruptibleChannel`, `ReadableByteChannel`, `ScatteringByteChannel`, `SeekableByteChannel`, `WritableByteChannel`

public class FilterFileChannel extends 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

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `FilterFileChannel.AbstractBuilder<F extends FilterFileChannel,C extends FileChannel,B extends FilterFileChannel.AbstractBuilder<F,C,B>>`
  Builds instances of `FilterFileChannel` for subclasses.
  `static class`
  `FilterFileChannel.Builder`
  Builds instances of `FilterFileChannel`.

  ## Nested classes/interfaces inherited from class java.nio.channels.FileChannel

  `FileChannel.MapMode`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FilterFileChannel(FileChannel fileChannel)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  `void`
  `force(boolean metaData)`
  `static FilterFileChannel.Builder`
  `forFilterFileChannel()`
  Creates a new `FilterFileChannel.Builder`.
  `int`
  `hashCode()`
  `protected void`
  `implCloseChannel()`
  `FileLock`
  `lock(long position, long size, boolean shared)`
  `MappedByteBuffer`
  `map(FileChannel.MapMode mode, long position, long size)`
  `long`
  `position()`
  `FileChannel`
  `position(long newPosition)`
  `int`
  `read(ByteBuffer dst)`
  `long`
  `read(ByteBuffer[] dsts, int offset, int length)`
  `int`
  `read(ByteBuffer dst, long position)`
  `long`
  `size()`
  `String`
  `toString()`
  `long`
  `transferFrom(ReadableByteChannel src, long position, long count)`
  `long`
  `transferTo(long position, long count, WritableByteChannel target)`
  `FileChannel`
  `truncate(long size)`
  `FileLock`
  `tryLock(long position, long size, boolean shared)`
  `FileChannel`
  `unwrap()`
  Unwraps this instance by returning the underlying `FileChannel`.
  `int`
  `write(ByteBuffer src)`
  `long`
  `write(ByteBuffer[] srcs, int offset, int length)`
  `int`
  `write(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 Details

  - ### FilterFileChannel

    public FilterFileChannel(FileChannel fileChannel)
    Constructs a new instance.
    Parameters:
      `fileChannel` - the file channel to wrap.

- ## Method Details

  - ### forFilterFileChannel

    public static FilterFileChannel.Builder forFilterFileChannel()
    Creates a new `FilterFileChannel.Builder`.
    Returns:
      a new `FilterFileChannel.Builder`.

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### force

    public void force(boolean metaData) throws IOException
    Specified by:
      `force` in class `FileChannel`
    Throws:
      `IOException`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### implCloseChannel

    protected void implCloseChannel() throws IOException
    Specified by:
      `implCloseChannel` in class `AbstractInterruptibleChannel`
    Throws:
      `IOException`

  - ### lock

    public FileLock lock(long position, long size, boolean shared) throws IOException
    Specified by:
      `lock` in class `FileChannel`
    Throws:
      `IOException`

  - ### map

    public MappedByteBuffer map(FileChannel.MapMode mode, long position, long size) throws IOException
    Specified by:
      `map` in class `FileChannel`
    Throws:
      `IOException`

  - ### position

    public long position() throws IOException
    Specified by:
      `position` in interface `SeekableByteChannel`
    Specified by:
      `position` in class `FileChannel`
    Throws:
      `IOException`

  - ### position

    public FileChannel position(long newPosition) throws IOException
    Specified by:
      `position` in interface `SeekableByteChannel`
    Specified by:
      `position` in class `FileChannel`
    Throws:
      `IOException`

  - ### read

    public int read(ByteBuffer dst) throws IOException
    Specified by:
      `read` in interface `ReadableByteChannel`
    Specified by:
      `read` in interface `SeekableByteChannel`
    Specified by:
      `read` in class `FileChannel`
    Throws:
      `IOException`

  - ### read

    public int read(ByteBuffer dst, long position) throws IOException
    Specified by:
      `read` in class `FileChannel`
    Throws:
      `IOException`

  - ### read

    public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
    Specified by:
      `read` in interface `ScatteringByteChannel`
    Specified by:
      `read` in class `FileChannel`
    Throws:
      `IOException`

  - ### size

    public long size() throws IOException
    Specified by:
      `size` in interface `SeekableByteChannel`
    Specified by:
      `size` in class `FileChannel`
    Throws:
      `IOException`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### transferFrom

    public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException
    Specified by:
      `transferFrom` in class `FileChannel`
    Throws:
      `IOException`

  - ### transferTo

    public long transferTo(long position, long count, WritableByteChannel target) throws IOException
    Specified by:
      `transferTo` in class `FileChannel`
    Throws:
      `IOException`

  - ### truncate

    public FileChannel truncate(long size) throws IOException
    Specified by:
      `truncate` in interface `SeekableByteChannel`
    Specified by:
      `truncate` in class `FileChannel`
    Throws:
      `IOException`

  - ### tryLock

    public FileLock tryLock(long position, long size, boolean shared) throws IOException
    Specified by:
      `tryLock` in class `FileChannel`
    Throws:
      `IOException`

  - ### unwrap

    public FileChannel unwrap()
    Unwraps this instance by returning the underlying `FileChannel`.

    Use with caution.

    Returns:
      the underlying `FileChannel`.

  - ### write

    public int write(ByteBuffer src) throws IOException
    Specified by:
      `write` in interface `SeekableByteChannel`
    Specified by:
      `write` in interface `WritableByteChannel`
    Specified by:
      `write` in class `FileChannel`
    Throws:
      `IOException`

  - ### write

    public int write(ByteBuffer src, long position) throws IOException
    Specified by:
      `write` in class `FileChannel`
    Throws:
      `IOException`

  - ### write

    public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
    Specified by:
      `write` in interface `GatheringByteChannel`
    Specified by:
      `write` in class `FileChannel`
    Throws:
      `IOException`