Java SE API

ByteBuffer.isDirect

Identify a direct buffer without inferring an exact storage footprint.

Formal Syntax & Structure

java syntaxjava
buffer.isDirect()

Working Example

Example Snippetjava
public class Main {
    public static void main(String[] args) throws Exception {        var heap = java.nio.ByteBuffer.allocate(4);        var direct = java.nio.ByteBuffer.allocateDirect(4);        System.out.println(heap.isDirect());        System.out.println(direct.isDirect());    }}
Java Reference