Strange behaviour of java.nio.charset.StandardCharsets.UTF8.newDecoder()

Xueming Shen xueming.shen at oracle.com
Fri Mar 18 18:36:24 UTC 2016


The decoder will NOT keep the "incomplete/leftover" byte(s) internally waiting
for your new bytes. Those bytes are left in your input ByteBuffer. You need to
fill the new bytes you have and feed the decoder again.


On 03/18/2016 11:38 AM, Pavel Rappo wrote:
> Why is that? I don't think I have to supply only "correct" chunks. After all,
> decoders are free to maintain an internal state needed for this.
>
>> On 18 Mar 2016, at 18:31, Martin Buchholz<martinrb at google.com>  wrote:
>>
>> trying to decode one byte at a time, which cannot
>> work?  The minimum unit to decode that will work is 4 bytes



More information about the nio-dev mailing list