import java.nio.ByteBuffer;
public class Main {
public static void main(String[] argv) throws Exception {
// Create a ByteBuffer using a byte array
byte[] bytes = new byte[10];
ByteBuffer buffer = ByteBuffer.wrap(bytes);
// Create a non-direct ByteBuffer with a 10 byte capacity
// The underlying storage is a byte array.
buffer = ByteBuffer.allocate(10);
// Create a memory-mapped ByteBuffer with a 10 byte capacity.
buffer = ByteBuffer.allocateDirect(10);
}
}
|