首页 > 解决方案 > 从 ByteBuffer 读取特殊的 UTF-8 字符

问题描述

如何从 ByteBuffer 中读取特殊字符?ByteBuffer.wrap("\u0001".getBytes()).asCharBuffer().get()抛出BufferUnderflow异常。据我所知ByteBuffer.getChar(),总是前进两个字节,而这个字符串中只有一个字节。

标签: javanio

解决方案


推荐阅读