创建一个ByteBuffer
import java.nio.ByteBuffer; //来 自 N o w J a v a . c o m - 时代Java public class Main { public void m() { // 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 buf = ByteBuffer.allocate(10); // Create a direct (memory-mapped) ByteBuffer with a 10 byte capacity. buf = ByteBuffer.allocateDirect(10);/**nowjava - 时代Java**/ } }