| java.lang.Object jj2000.j2k.entropy.decoder.ByteInputBuffer
ByteInputBuffer | public class ByteInputBuffer (Code) | | This class provides a byte input facility from byte buffers. It is similar
to the ByteArrayInputStream class, but adds the possibility to add data to
the stream after the creation of the object.
Unlike the ByteArrayInputStream this class is not thread safe (i.e. no
two threads can use the same object at the same time, but different objects
may be used in different threads).
This class can modify the contents of the buffer given to the
constructor, when the addByteArray() method is called.
See Also: InputStream |
Constructor Summary | |
public | ByteInputBuffer(byte buf) Creates a new byte array input stream that reads data from the
specified byte array. | public | ByteInputBuffer(byte buf, int offset, int length) Creates a new byte array input stream that reads data from the
specified byte array. |
Method Summary | |
public synchronized void | addByteArray(byte data, int off, int len) Adds the specified data to the end of the byte array stream. | public int | read() Reads the next byte of data from this input stream. | public int | readChecked() Reads the next byte of data from this input stream. | public void | setByteArray(byte buf, int offset, int length) Sets the underlying buffer byte array to the given one, with the given
offset and length. |
ByteInputBuffer | public ByteInputBuffer(byte buf)(Code) | | Creates a new byte array input stream that reads data from the
specified byte array. The byte array is not copied.
Parameters: buf - the input buffer. |
ByteInputBuffer | public ByteInputBuffer(byte buf, int offset, int length)(Code) | | Creates a new byte array input stream that reads data from the
specified byte array. Up to length characters are to be read
from the byte array, starting at the indicated offset.
The byte array is not copied.
Parameters: buf - the input buffer. Parameters: offset - the offset in the buffer of the first byte toread. Parameters: length - the maximum number of bytes to read from thebuffer. |
addByteArray | public synchronized void addByteArray(byte data, int off, int len)(Code) | | Adds the specified data to the end of the byte array stream. This
method modifies the byte array buffer. It can also discard the already
read input.
Parameters: data - The data to add. The data is copied. Parameters: off - The index, in data, of the first element to add tothe stream. Parameters: len - The number of elements to add to the array. |
read | public int read()(Code) | | Reads the next byte of data from this input stream. 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, -1 is returned.
This method is not synchronized, so it is not thread safe.
The byte read in the range 0-255, or -1 if the end of streamhas been reached. |
readChecked | public int readChecked() throws IOException(Code) | | Reads the next byte of data from this input stream. 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
EOFException exception is thrown.
This method is not synchronized, so it is not thread safe.
The byte read in the range 0-255. exception: EOFException - If the end of the stream is reached. |
setByteArray | public void setByteArray(byte buf, int offset, int length)(Code) | | Sets the underlying buffer byte array to the given one, with the given
offset and length. If 'buf' is null then the current byte buffer is
assumed. If 'offset' is negative, then it will be assumed to be
'off+len', where 'off' and 'len' are the offset and length of the
current byte buffer.
The byte array is not copied.
Parameters: buf - the input buffer. If null it is the current input buffer. Parameters: offset - the offset in the buffer of the first byte to read. Ifnegative it is assumed to be the byte just after the end of the currentinput buffer, only permitted if 'buf' is null. Parameters: length - the maximum number of bytes to read frmo the buffer. |
|
|