Code example for CharsetDecoder

Methods: decode

0
            chars.limit(0);
            return; 
        } 
        bytes.limit(read);
        boolean endOfInput = read < DEFAULT_BUFFER_SIZE;
        CoderResult result = decoder.decode(bytes, chars, endOfInput);
        if (result.isError()) {
            throw new IOException(result.toString());
        } 
        bytes.clear();
        chars.flip();
    } 
 
    /* 
     * Write method for OutputStreamWriter and Channels. 
     */ 
    public static void writeOutputStreamWriter(String str, int offset,
            int count, OutputStream out, ByteBuffer bytes,
            CharsetEncoder encoder, Object lock) throws IOException {
        Util.assertArrayIndex(str.length(), offset, count);
        CharBuffer chars = CharBuffer.wrap(str, offset, count + offset);