import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.IntBuffer;
public class TestDirect {
public static void main(String[] args) {
//直接缓冲,创建时间长,高效读写。
ByteBuffer bb = ByteBuffer.allocateDirect(16);//先建byte的直接缓冲。
CharBuffer cb = bb.asCharBuffer();//其它类型的缓冲都是调用.as..Buffer()得到。
IntBuffer ib = bb.asIntBuffer();
System.out.println(bb.capacity());
System.out.println(cb.capacity());
System.out.println(ib.capacity());
}
}