开发者

What is the difference between ByteBuffer and CharBuffer in Java NIO?

What is difference between ByteBuffer and CharBuffer in case java.nio package. Is it the sa开发者_如何学Cme difference as byte and char has?


Mostly, yes - but ByteBuffers also have operations for viewing a ByteBuffer as other kinds of buffer (e.g. asDoubleBuffer), and for putting other primitive types into the buffer, (e.g. putLong).

CharBuffer also implements Appendable and CharSequence, making it easier to work with for text operations.


You can see it like that. A ByteBuffer is a buffer for (8-bit) byte values while a CharBuffer holds (16-bit) chars.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜