Determining If a ByteBuffer Is Direct - Java File Path IO

Java examples for File Path IO:ByteBuffer

Description

Determining If a ByteBuffer Is Direct

Demo Code

import java.nio.ByteBuffer;

public class Main {

  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
  }//from  w  w w. j a v  a2  s  .c  o m
}

Related Tutorials