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
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 ClassesModifier and TypeClassDescriptionstatic classFilterFileChannel.AbstractBuilder<F extends FilterFileChannel,C extends FileChannel, B extends FilterFileChannel.AbstractBuilder<F, C, B>> Builds instances ofFilterFileChannelfor subclasses.static classBuilds instances ofFilterFileChannel.Nested classes/interfaces inherited from class java.nio.channels.FileChannel
FileChannel.MapMode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidforce(boolean metaData) static FilterFileChannel.BuilderCreates a newFilterFileChannel.Builder.inthashCode()protected voidlock(long position, long size, boolean shared) map(FileChannel.MapMode mode, long position, long size) longposition()position(long newPosition) intread(ByteBuffer dst) longread(ByteBuffer[] dsts, int offset, int length) intread(ByteBuffer dst, long position) longsize()toString()longtransferFrom(ReadableByteChannel src, long position, long count) longtransferTo(long position, long count, WritableByteChannel target) truncate(long size) tryLock(long position, long size, boolean shared) unwrap()Unwraps this instance by returning the underlyingFileChannel.intwrite(ByteBuffer src) longwrite(ByteBuffer[] srcs, int offset, int length) intwrite(ByteBuffer src, long position) Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
Constructor Details
-
FilterFileChannel
Constructs a new instance.- Parameters:
fileChannel- the file channel to wrap.
-
-
Method Details
-
forFilterFileChannel
Creates a newFilterFileChannel.Builder.- Returns:
- a new
FilterFileChannel.Builder.
-
equals
-
force
- Specified by:
forcein classFileChannel- Throws:
IOException
-
hashCode
-
implCloseChannel
- Specified by:
implCloseChannelin classAbstractInterruptibleChannel- Throws:
IOException
-
lock
- Specified by:
lockin classFileChannel- Throws:
IOException
-
map
- Specified by:
mapin classFileChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Specified by:
positionin classFileChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Specified by:
positionin classFileChannel- Throws:
IOException
-
read
- Specified by:
readin interfaceReadableByteChannel- Specified by:
readin interfaceSeekableByteChannel- Specified by:
readin classFileChannel- Throws:
IOException
-
read
- Specified by:
readin classFileChannel- Throws:
IOException
-
read
- Specified by:
readin interfaceScatteringByteChannel- Specified by:
readin classFileChannel- Throws:
IOException
-
size
- Specified by:
sizein interfaceSeekableByteChannel- Specified by:
sizein classFileChannel- Throws:
IOException
-
toString
-
transferFrom
- Specified by:
transferFromin classFileChannel- Throws:
IOException
-
transferTo
- Specified by:
transferToin classFileChannel- Throws:
IOException
-
truncate
- Specified by:
truncatein interfaceSeekableByteChannel- Specified by:
truncatein classFileChannel- Throws:
IOException
-
tryLock
- Specified by:
tryLockin classFileChannel- Throws:
IOException
-
unwrap
Unwraps this instance by returning the underlyingFileChannel.Use with caution.
- Returns:
- the underlying
FileChannel.
-
write
- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Specified by:
writein classFileChannel- Throws:
IOException
-
write
- Specified by:
writein classFileChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceGatheringByteChannel- Specified by:
writein classFileChannel- Throws:
IOException
-