Code example for CharsetDecoder

Methods: decodeflushreset

0
     * test flush 
     */ 
    public void testFlush() throws CharacterCodingException {
        CharBuffer out = CharBuffer.allocate(10);
        ByteBuffer in = ByteBuffer.wrap(new byte[] { 12, 12 });
        decoder.decode(in, out, true);
        assertSame(CoderResult.UNDERFLOW, decoder.flush(out));
 
        decoder.reset();
        decoder.decode((ByteBuffer) in.rewind(), (CharBuffer) out.rewind(),
                true); 
        assertSame(CoderResult.UNDERFLOW, decoder
                .flush(CharBuffer.allocate(10)));
    } 
 
    /* 
     * ---------------------------------- methods to test illegal state 
     * ----------------------------------- 
     */ 
    // Normal case: just after reset, and it also means reset can be done