Code example for CharsetDecoder

Methods: decodeflushreset

0
		byte[] bytes = { (byte) 0xE3, (byte) 0x81, (byte) 0x61 };
		ByteBuffer in = ByteBuffer.wrap(bytes);
		CharBuffer small = CharBuffer.allocate(1);
		CharBuffer result = CharBuffer.allocate(10);
 
		decoder.reset();
		assertTrue(decoder.decode(in, small, true).isOverflow());
		small.flip();
		assertEquals(1, small.length());
		result.put(small.get());
		small.clear();
		assertTrue(decoder.decode(in, small, true).isOverflow());
		small.flip();
		assertEquals(1, small.length());
		result.put(small.get());
		assertTrue(decoder.decode(in, result, true).isUnderflow());
		assertTrue(decoder.flush(result).isUnderflow());
		result.flip();
		assertEquals("\u00E3\u0081a", result.toString());
	} 
 
	@Test 
Connect your IDE to all the code out there  Get Codota for Java