public final class UTF8ByteBufferReader extends Reader
A UTF-8 java.nio.ByteBuffer reader.
This reader can be used for efficient decoding of native byte
buffers (e.g. MappedByteBuffer), high-performance
messaging (no intermediate buffer), etc.
This reader supports surrogate char pairs (representing
characters in the range [U+10000 .. U+10FFFF]). It can also be used
to read characters unicodes (31 bits) directly
(ref. read()).
Each invocation of one of the read() methods may cause one
or more bytes to be read from the underlying byte buffer.
The end of stream is reached when the byte buffer position and limit
coincide.
UTF8ByteBufferWriter| Constructor and Description |
|---|
UTF8ByteBufferReader()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes and
resets this reader for reuse. |
int |
read()
Reads a single character.
|
void |
read(Appendable dest)
Reads characters into the specified appendable.
|
int |
read(char[] cbuf,
int off,
int len)
Reads characters into a portion of an array.
|
boolean |
ready()
Indicates if this stream is ready to be read.
|
void |
reset() |
UTF8ByteBufferReader |
setByteBuffer(ByteBuffer byteBuffer)
Deprecated.
Replaced by
setInput(ByteBuffer) |
UTF8ByteBufferReader |
setInput(ByteBuffer byteBuffer)
Sets the
ByteBuffer to use for reading available bytes
from current buffer position. |
public UTF8ByteBufferReader setInput(ByteBuffer byteBuffer)
ByteBuffer to use for reading available bytes
from current buffer position.byteBuffer - the ByteBuffer source.IllegalStateException - if this reader is being reused and
it has not been closed or reset.public boolean ready()
throws IOException
ready in class Readertrue if the byte buffer has remaining bytes to
read; false otherwise.IOException - if an I/O error occurs.public void close()
throws IOException
resets this reader for reuse.close in interface Closeableclose in interface AutoCloseableclose in class ReaderIOException - if an I/O error occurs.public int read()
throws IOException
-1
is returned if the buffer's limit has been reached.read in class ReaderIOException - if an I/O error occurs (e.g. incomplete
character sequence being read).public int read(char[] cbuf,
int off,
int len)
throws IOException
Note: Characters between U+10000 and U+10FFFF are represented
by surrogate pairs (two char).
read in class Readercbuf - the destination buffer.off - the offset at which to start storing characters.len - the maximum number of characters to readIOException - if an I/O error occurs.public void read(Appendable dest) throws IOException
Note: Characters between U+10000 and U+10FFFF are represented
by surrogate pairs (two char).
dest - the destination buffer.IOException - if an I/O error occurs.public UTF8ByteBufferReader setByteBuffer(ByteBuffer byteBuffer)
setInput(ByteBuffer)Copyright © 2005-2013 Javolution. All Rights Reserved.