Code example for CharsetDecoder

Methods: decode

0
    } 
 
    void implTestDecodeByteBuffer() throws CharacterCodingException {
        // Null pointer 
        try { 
            decoder.decode(null);
            fail("should throw null pointer exception");
        } catch (NullPointerException e) {
        } 
 
        // empty input buffer 
        CharBuffer out = decoder.decode(ByteBuffer.allocate(0));
        assertCharBufferValue("", out);
 
        // normal case 
        ByteBuffer in = getByteBuffer();
        out = decoder.decode(in);
        assertEquals(0, out.position());
        assertEquals(getString().length(), out.limit());
        assertEquals(getString().length(), out.remaining());
        assertCharBufferValue(getString(), out);
 
        // normal read only case 
        in = getByteBuffer().asReadOnlyBuffer();
        out = decoder.decode(in);
        assertEquals(out.position(), 0);
        assertEquals(out.limit(), getString().length());
        assertEquals(out.remaining(), getString().length());
        assertCharBufferValue(getString(), out);
    } 
Connect your IDE to all the code out there  Get Codota for Java