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 ByteBuffer
s 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
.
精彩评论