public class CipherInputStream extends FilterInputStream
InputStream
that filters its data
through a Cipher
before returning it. The Cipher
argument must have been initialized before it is passed to the
constructor.in
Modifier | Constructor and Description |
---|---|
protected |
CipherInputStream(InputStream in)
Creates a new input stream without a cipher.
|
|
CipherInputStream(InputStream in,
Cipher cipher)
Creates a new input stream with a source input stream and cipher.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes available without blocking.
|
void |
close()
Close this input stream.
|
void |
mark(int mark)
Set the mark.
|
boolean |
markSupported()
Returns whether or not this input stream supports the
#mark(long) and reset() methods; this input stream does
not, however, and invariably returns false . |
int |
read()
Read a single byte from this input stream; returns -1 on the
end-of-file.
|
int |
read(byte[] buf)
Read bytes into an array, returning the number of bytes read or -1
on the end-of-file.
|
int |
read(byte[] buf,
int off,
int len)
Read bytes into an array, returning the number of bytes read or -1
on the end-of-file.
|
void |
reset()
Reset to the mark.
|
long |
skip(long bytes)
Skip a number of bytes.
|
public CipherInputStream(InputStream in, Cipher cipher)
in
- The underlying input stream.cipher
- The cipher to filter data through.protected CipherInputStream(InputStream in)
protected
because this class does not work without an
underlying cipher.in
- The underlying input stream.public int available() throws IOException
available
in class FilterInputStream
IOException
- If an I/O exception occurs.public void close() throws IOException
InputStream.close()
method of the underlying input stream.close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
- If an I/O exception occurs.public int read() throws IOException
read
in class FilterInputStream
java.io.IOExcpetion
- If an I/O exception occurs.IOException
- If an error occurspublic int read(byte[] buf, int off, int len) throws IOException
read
in class FilterInputStream
buf
- The byte array to read into.off
- The offset in buf
to start.len
- The maximum number of bytes to read.IOException
- If an I/O exception occurs.public int read(byte[] buf) throws IOException
read
in class FilterInputStream
buf
- The byte arry to read into.IOException
- If an I/O exception occurs.public long skip(long bytes) throws IOException
available()
, which is the number
of transformed bytes currently in this class's internal buffer.skip
in class FilterInputStream
bytes
- The number of bytes to skip.IOException
- If an error occurspublic boolean markSupported()
#mark(long)
and reset()
methods; this input stream does
not, however, and invariably returns false
.markSupported
in class FilterInputStream
false
public void mark(int mark)
mark
in class FilterInputStream
mark
- Is ignored.public void reset() throws IOException
reset
in class FilterInputStream
IOException
- If an error occurs