Code example for CharBuffer

Methods: array

		MockCharset c1 = new MockCharset("mock", null);
		CharBuffer cb = c1.decode(ByteBuffer.wrap("abcdefg"
		assertEquals("abcdefg", new String(cb.array()));
		cb = c1.decode(ByteBuffer.wrap("".getBytes("iso8859-1")));
		assertEquals("", new String(cb.array()));
	 * Test the method decode(ByteBuffer) with a malformed input. 
	public void testDecode_Malformed() throws Exception { 
		Charset c1 = Charset.forName("iso8859-1");
		CharBuffer cb = c1.decode(ByteBuffer.wrap("abcd\u5D14efg"
		byte[] replacement = c1.newEncoder().replacement();
		assertEquals(new String(cb.array()).trim(), "abcd" + new String(replacement, "iso8859-1")
				+ "efg"); 
Connect your IDE to all the code out there  Get Codota for Java