Class ChannelInput
java.lang.Object
org.apache.commons.crypto.stream.input.ChannelInput
- All Implemented Interfaces:
Closeable, AutoCloseable, Input
The ChannelInput class takes a
ReadableByteChannel object and
wraps it as Input object acceptable by
CryptoInputStream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBufferprivate final ReadableByteChannelprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintOverrides theInput.available().voidclose()Overrides theInput.seek(long).private ByteBufferGets the skip buffer.intread(long position, byte[] buffer, int offset, int length) Overrides theInput.read(long, byte[], int, int).intread(ByteBuffer dst) Overrides theInput.read(ByteBuffer).voidseek(long position) Overrides theInput.seek(long).longskip(long n) Overrides theInput.skip(long).
-
Field Details
-
SKIP_BUFFER_SIZE
private static final int SKIP_BUFFER_SIZE- See Also:
-
buf
-
channel
-
-
Constructor Details
-
ChannelInput
Constructs theChannelInput.- Parameters:
channel- the ReadableByteChannel object.
-
-
Method Details
-
available
Overrides theInput.available(). Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.- Specified by:
availablein interfaceInput- Returns:
- an estimate of the number of bytes that can be read (or skipped
over) from this input stream without blocking or
0when it reaches the end of the input stream. - Throws:
IOException- if an I/O error occurs.
-
close
Overrides theInput.seek(long). Closes this input and releases any system resources associated with the under layer input.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceInput- Throws:
IOException- if an I/O error occurs.
-
getSkipBuf
-
read
Overrides theInput.read(ByteBuffer). Reads a sequence of bytes from input into the given buffer.- Specified by:
readin interfaceInput- Parameters:
dst- The buffer into which bytes are to be transferred.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occurs.
-
read
Overrides theInput.read(long, byte[], int, int). Reads up tolenbytes of data from the input stream into an array of bytes. An attempt is made to read as many aslenbytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.- Specified by:
readin interfaceInput- Parameters:
position- the given position within a stream.buffer- the buffer into which the data is read.offset- the start offset in array buffer.length- the maximum number of bytes to read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occurs.
-
seek
Overrides theInput.seek(long). Seeks to the given offset from the start of the stream. The next read() will be from that location.- Specified by:
seekin interfaceInput- Parameters:
position- the offset from the start of the stream.- Throws:
IOException- if an I/O error occurs.
-
skip
Overrides theInput.skip(long). Skips over and discardsnbytes of data from this input stream.- Specified by:
skipin interfaceInput- Parameters:
n- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped.
- Throws:
IOException- if an I/O error occurs.
-