ByteBuffer to CharBuffer

Jay jay.sridhar at
Mon Feb 6 10:57:24 UTC 2017

java.nio.ByteBuffer provides a method asCharBuffer() which returns a
"view" of the ByteBuffer as a character buffer. It however does not
take any arguments. And there is no mention in the Javadocs as to how
it converts from bytes to chars.

1. There should be a method ByteBuffer.asCharBuffer(CharSet) and/or
ByteBuffer.asCharBuffer(String charSet) which allows the user to
explicitly specify the character set to be used for conversion.

2. The method ByteBuffer.asCharBuffer() should mention that this
method uses the platform default charset for bytes-to-chars

I can provide a patch with these two changes. What do you guys think?

More information about the core-libs-dev mailing list