public class CoderInputStream
extends java.io.FilterInputStream
To specify the Coder object that is used by the input stream to encode or decode the data, use the setCoder() method.
After filling a buffer of block size, the Coder object is used to encode or decode the buffer. The setMode() method is used to specify encoding or decoding mode (the default mode is decode.)
An IOException is thrown if there is not enough data to fill the buffer.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf
The buffer which stores the data.
|
protected Coder |
coder
The Coder used by this stream.
|
protected int |
count
The number of bytes in the buffer.
|
static int |
DECODE_MODE
The DECODE mode.
|
static int |
ENCODE_MODE
The ENCODE mode.
|
protected int |
mode
the current mode
|
Constructor and Description |
---|
CoderInputStream(java.io.InputStream is, Coder c)
Create a new CoderInputStream with the buffer size equal to the Coder block size.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Return the number of bytes that can be read without blocking.
|
Coder |
getCoder()
Get the Coder used in this stream.
|
int |
getMode()
Get the current mode.
|
int |
read()
Read one byte of data.
|
int |
read(byte[] b, int off, int len)
Reads into an array of bytes.
|
void |
setMode(int m)
Set the mode of the stream.
|
public static final int DECODE_MODE
public static final int ENCODE_MODE
protected int mode
protected Coder coder
protected byte[] buf
protected int count
public CoderInputStream(java.io.InputStream is, Coder c)
public Coder getCoder()
public int getMode()
public void setMode(int m)
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
b
- the buffer which the data is read intooff
- start offset of datalen
- maximum number of bytes readjava.io.IOException
public int available() throws java.io.IOException
available
in class java.io.FilterInputStream
java.io.IOException