确定ByteBuffer是否直接
import java.nio.ByteBuffer; public class Main {//时 代 Java 公 众 号 - nowjava.com 提供 public void main(String[] argv) { ByteBuffer bbuf = ByteBuffer.wrap(new byte[10]); boolean isDirect = bbuf.isDirect(); // false bbuf = ByteBuffer.allocate(10); isDirect = bbuf.isDirect(); // false bbuf = ByteBuffer.allocateDirect(10); isDirect = bbuf.isDirect(); // true } }