public class StreamInput extends Object implements Input
InputStream object and wraps it as
Input object acceptable by CryptoInputStream.| Constructor and Description |
|---|
StreamInput(InputStream inputStream,
int bufferSize)
Constructs a
StreamInput. |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Overrides the
Input.available(). |
void |
close()
Overrides the
Input.seek(long). |
int |
read(ByteBuffer dst)
Overrides the
Input.read(ByteBuffer). |
int |
read(long position,
byte[] buffer,
int offset,
int length)
Overrides the
Input.read(long, byte[], int, int)
. |
void |
seek(long position)
Overrides the
Input.seek(long). |
long |
skip(long n)
Overrides the
Input.skip(long). |
public StreamInput(InputStream inputStream, int bufferSize)
StreamInput.inputStream - the InputStream object.bufferSize - the buffer size.public int available() throws IOException
Input.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.available in interface Input0 when
it reaches the end of the input stream.IOException - if an I/O error occurs.public void close() throws IOException
Input.seek(long). Closes
this input and releases any system resources associated with the under
layer input.close in interface Closeableclose in interface AutoCloseableclose in interface InputIOException - if an I/O error occurs.public int read(ByteBuffer dst) throws IOException
Input.read(ByteBuffer).
Reads a sequence of bytes from input into the given buffer.read in interface Inputdst - The buffer into which bytes are to be transferred.EOS (-1) if there is no more data because the end of the
stream has been reached.IOException - if an I/O error occurs.public int read(long position, byte[] buffer, int offset, int length) throws IOException
Input.read(long, byte[], int, int)
. Reads up to len bytes of data from the input stream into
an array of bytes. An attempt is made to read as many as len
bytes, but a smaller number may be read. The number of bytes actually
read is returned as an integer.read in interface Inputposition - 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.EOS (-1) if there is no more data because the end of the
stream has been reached.IOException - if an I/O error occurs.public void seek(long position) throws IOException
Input.seek(long). Seeks to
the given offset from the start of the stream. The next read() will be
from that location.seek in interface Inputposition - the offset from the start of the stream.IOException - if an I/O error occurs.public long skip(long n) throws IOException
Input.skip(long). Skips
over and discards n bytes of data from this input stream.skip in interface Inputn - the number of bytes to be skipped.IOException - if an I/O error occurs.Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.