encoder and decoder use a supplied ByteBuffer : Charset « I18N « Java Tutorial






import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;

public class Main {
  public static void main(String[] argv) throws Exception {
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();
    CharsetEncoder encoder = charset.newEncoder();
    ByteBuffer bbuf = ByteBuffer.allocateDirect(1024);

    CharBuffer cbuf = CharBuffer.allocate(1024);

    encoder.encode(cbuf, bbuf, false);

    bbuf.flip();

    decoder.decode(bbuf, cbuf, false);

    cbuf.flip();

  }
}








13.20.Charset
13.20.1.Listing All Available Unicode to Character Set Converters
13.20.2.Converting Between Strings (Unicode) and Other Character Set Encodings
13.20.3.encoder and decoder use a supplied ByteBuffer
13.20.4.Detect non-ASCII characters in string
13.20.5.List Charsets
13.20.6.Translate Charset
13.20.7.extends Charset to create Hex Charset