public class Coder
extends java.lang.Object
methods to encode/decode between a
java.lang.StringBuilder
and a
java.nio.ByteBuffer
.
Constructor and Description |
---|
Coder(java.nio.charset.Charset chs)
creates an
Coder for the given character set
which uses a default internal buffer size for encoding. |
Modifier and Type | Method and Description |
---|---|
void |
decode(java.nio.ByteBuffer in,
java.lang.StringBuilder out)
decode the contents of a
ByteBuffer and append them
to a StringBuilder . |
java.nio.ByteBuffer |
encode(java.lang.StringBuilder in,
java.nio.ByteBuffer out)
encode the contends of a
StringBuilder into a
ByteBuffer . |
void |
setDecoder(java.nio.charset.CharsetDecoder dec)
sets the decoder to use.
|
void |
setEncoder(java.nio.charset.CharsetEncoder enc,
int chBsize)
sets the encoder to use and requests to use a character buffer
size of at least
chBsize internally. |
public Coder(java.nio.charset.Charset chs)
creates an Coder
for the given character set
which uses a default internal buffer size for encoding.
public void setEncoder(java.nio.charset.CharsetEncoder enc, int chBsize)
sets the encoder to use and requests to use a character buffer
size of at least chBsize
internally.
public void setDecoder(java.nio.charset.CharsetDecoder dec)
sets the decoder to use.
public void decode(java.nio.ByteBuffer in, java.lang.StringBuilder out) throws java.nio.charset.CharacterCodingException
ByteBuffer
and append them
to a StringBuilder
.in
- must be in flipped mode, i.e. ready to be read fromjava.nio.charset.CharacterCodingException
public java.nio.ByteBuffer encode(java.lang.StringBuilder in, java.nio.ByteBuffer out) throws java.nio.charset.CharacterCodingException
encode the contends of a StringBuilder
into a
ByteBuffer
.
ByteBuffer
or a freshly
allocated, if the given one is too short.java.nio.charset.CharacterCodingException