Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
java.nio 包中的 ByteBuffer 和 CharBuffer 有什么区别。它与 byte 和 char 有相同的区别吗?
大多数情况下,是的 - 但ByteBuffers 也有将 aByteBuffer视为其他类型的缓冲区(例如asDoubleBuffer)以及将其他原始类型放入缓冲区(例如putLong)的操作。
ByteBuffer
asDoubleBuffer
putLong
CharBuffer还实现了Appendableand CharSequence,使其更容易用于文本操作。
CharBuffer
Appendable
CharSequence
你可以这样看。ByteBuffer 是(8 位)byte值的缓冲区,而 CharBuffer 保存(16 位)chars。
byte
chars