Package com.mastfrog.util.streams
Interface GeneralByteChannel
- All Superinterfaces:
AutoCloseable,ByteChannel,Channel,Closeable,ReadableByteChannel,SeekableByteChannel,WritableByteChannel
public interface GeneralByteChannel
extends ReadableByteChannel, SeekableByteChannel, WritableByteChannel
Encapsulates ReadableByteChannel, SeekableByteChannel, WritableByteChannel
to have a single type to return from Streams.channel() which is compatible
with APIs that take the types implemented by FileChannel.
- Author:
- Tim Boudreau
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the same value as position(), but as an int, since Java arrays do not support > Integer.MAX_VALUE arrays, so it will always fit.position(long newPosition) intreset()Reset the channel's position and closed state (if possible); useful for avoiding copies in the case of a channel that is used for writes and then reads.truncate(long size) Methods inherited from interface java.nio.channels.SeekableByteChannel
position, read, size, write
-
Method Details
-
truncate
- Specified by:
truncatein interfaceSeekableByteChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
cursorPosition
int cursorPosition()Returns the same value as position(), but as an int, since Java arrays do not support > Integer.MAX_VALUE arrays, so it will always fit.- Returns:
- The position of the channel at present
-
reset
int reset()Reset the channel's position and closed state (if possible); useful for avoiding copies in the case of a channel that is used for writes and then reads.- Returns:
- The channel position at the time of reset
- Throws:
UnsupportedOperationException- if unsupported
-