public class PKCS7EncodeStream.ConsumerInputStream
extends java.io.InputStream
The buffer is a circular buffer. The first data byte is at
m_readIndex, the last data byte is at m_writeIndex - 1.
m_writeIndex == m_readIndex indicates an empty buffer.
m_writeIndex == m_readIndex - 1 indicates a full buffer.
The buffer can hold only buffer.size-1 bytes.
| Constructor and Description |
|---|
PKCS7EncodeStream.ConsumerInputStream(int bufferSize)
Creates a
ConsumerInputStream object with the specified buffer
size. |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of bytes that can be read from this input stream
without blocking.
|
void |
close()
Closes this input stream.
|
java.io.IOException |
getException()
Returns the exception to the producer.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read()
Reads the next byte of data from this input stream.
|
int |
read(byte[] b)
Reads up to
b.length bytes of data from this input stream
into an array of bytes. |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from this input stream into
an array of bytes. |
void |
reset() |
void |
setException(java.io.IOException e)
Allows the consumer to pass an exception to the producer.
|
long |
skip(long n)
Skips over and discards
n bytes of data from the buffer. |
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array. |
void |
write(int b)
Writes one byte to the buffer.
|
public PKCS7EncodeStream.ConsumerInputStream(int bufferSize)
throws java.lang.IllegalArgumentException
ConsumerInputStream object with the specified buffer
size.
bufferSize - the size of the internal bufferjava.lang.IllegalArgumentException - thrown if bufferSize is below 2public void write(int b)
throws java.io.IOException
If the buffer is full, this method blocks until there is space left in the buffer.
b - the byte to write to the bufferjava.io.IOException - thrown if the input stream is closedpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes from the specified byte array.
The method starts with offset off of the buffer. If the
buffer is full, the method blocks until there is enough space to write
the data to the buffer.
b - the dataoff - the start offset in the datalen - the number of bytes to writejava.io.IOException - thrown if the input stream is closedjava.lang.ArrayIndexOutOfBoundsException - thrown if off or off+len-1 are
not within the bounds of bpublic int available()
available in class java.io.InputStreampublic int read()
The value byte is returned as an int in the range
0 to 255. If no byte is available because the
end of the stream has been reached, the value -1 is returned.
This method blocks until input data is available, the end of the stream is detected,
or an exception is thrown.
read in class java.io.InputStream-1 if the end of the
stream is reachedpublic int read(byte[] b)
b.length bytes of data from this input stream
into an array of bytes.
This method calls read(b, 0, b.length).
read in class java.io.InputStreamb - the buffer into which the data is read-1 if there is no more data because the end of the
stream has been reachedpublic int read(byte[] b,
int off,
int len)
len bytes of data from this input stream into
an array of bytes.
This method blocks until some input is available. If the argument
b is null, a NullPointerException
is thrown.
read in class java.io.InputStreamb - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes read-1 if there is no more data because the end of the
stream has been reachedpublic long skip(long n)
n bytes of data from the buffer.
There are a number of reasons why the skip method might
skip over a number of bytes smaller than n, possibly
0. The actual number of bytes skipped is always returned.
skip in class java.io.InputStreamn - the number of bytes to be skippedpublic void close()
After reading all remaining data from the buffer, the reader will not block, but receives an end of stream message.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreampublic boolean markSupported()
markSupported in class java.io.InputStreampublic void mark(int readlimit)
mark in class java.io.InputStreampublic void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionpublic void setException(java.io.IOException e)
e - the exception that the consumer wants to pass to the
producerpublic java.io.IOException getException()
null if the consumer has run without errors