📄 e158. creating a bytebuffer.txt
字号:
A ByteBuffer is a fixed-capacity buffer that holds byte values. This example demonstrates a number of ways to create a ByteBuffer.
See also e159 Getting Bytes from a ByteBuffer and e160 Putting Bytes into a ByteBuffer.
// Create a ByteBuffer using a byte array
byte[] bytes = new byte[10];
ByteBuffer buf = ByteBuffer.wrap(bytes);
// Create a non-direct ByteBuffer with a 10 byte capacity
// The underlying storage is a byte array.
buf = ByteBuffer.allocate(10);
// Create a direct (memory-mapped) ByteBuffer with a 10 byte capacity.
buf = ByteBuffer.allocateDirect(10);
// To create a ByteBuffer for a memory-mapped file,
// see e166 Creating a Memory-Mapped File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -