开发者

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

开发者 https://www.devze.com 2023-01-24 11:52 出处:网络
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 viewi

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

精彩评论

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