集册 Java实例教程 确定ByteBuffer是否直接

确定ByteBuffer是否直接

欢马劈雪     最近更新时间:2020-01-02 10:19:05

515
确定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

  }

}