简体   繁体   中英

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 same difference as byte and char has?

Mostly, yes - but ByteBuffer s also have operations for viewing a ByteBuffer as other kinds of buffer (eg asDoubleBuffer ), and for putting other primitive types into the buffer, (eg 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM