Code example for CharsetDecoder

Methods: decode, onUnmappableCharacter

      charsetName = DEFAULT_CHARSET;
    Charset charset = Charset.forName(charsetName);
    CharsetDecoder decoder = charset.newDecoder();
    CharsetEncoder encoder = charset.newEncoder();
    // Convert a string to charsetName bytes in a ByteBuffer 
    // The new ByteBuffer is ready to be read. 
    ByteBuffer buf = encoder.encode(CharBuffer.wrap(str));
    // Convert charsetName bytes in a ByteBuffer to a character ByteBuffer 
    // and then to a string. The new ByteBuffer is ready to be read. 
    CharBuffer cbuf = decoder.decode(buf);
    return cbuf.toString();
   * concatenate nio-ByteBuffers 
   * @param buffers 
   *          ArrayList<ByteBuffer>