Class StreamInput
- java.lang.Object
-
- org.apache.commons.crypto.stream.input.StreamInput
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Input
public class StreamInput extends java.lang.Object implements Input
The StreamInput class takes aInputStreamobject and wraps it asInputobject acceptable byCryptoInputStream.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bufprivate intbufferSize(package private) java.io.InputStreamin
-
Constructor Summary
Constructors Constructor Description StreamInput(java.io.InputStream inputStream, int bufferSize)Constructs aStreamInput.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Overrides theInput.available().voidclose()Overrides theInput.seek(long).intread(long position, byte[] buffer, int offset, int length)Overrides theInput.read(long, byte[], int, int).intread(java.nio.ByteBuffer dst)Overrides theInput.read(ByteBuffer).voidseek(long position)Overrides theInput.seek(long).longskip(long n)Overrides theInput.skip(long).
-
-
-
Constructor Detail
-
StreamInput
public StreamInput(java.io.InputStream inputStream, int bufferSize)Constructs aStreamInput.- Parameters:
inputStream- the InputStream object.bufferSize- the buffer size.
-
-
Method Detail
-
available
public int available() throws java.io.IOExceptionOverrides 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.
-
close
public void close() throws java.io.IOExceptionOverrides theInput.seek(long). Closes this input and releases any system resources associated with the under layer input.
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOExceptionOverrides 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
EOS (-1)if there is no more data because the end of the stream has been reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read(long position, byte[] buffer, int offset, int length) throws java.io.IOExceptionOverrides 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
EOS (-1)if there is no more data because the end of the stream has been reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
seek
public void seek(long position) throws java.io.IOExceptionOverrides theInput.seek(long). Seeks to the given offset from the start of the stream. The next read() will be from that location.
-
skip
public long skip(long n) throws java.io.IOExceptionOverrides theInput.skip(long). Skips over and discardsnbytes of data from this input stream.
-
-