ByteBuffer isDirect() in Java

isDirect(): This method is available in java.nio.ByteBuffer class of Java.

Syntax:

boolean java.nio.ByteBuffer.isDirect()

This method tells whether or not this byte buffer is direct.

Parameters: NA

Returns: true if, and only if, this buffer is direct.

Exceptions: NA

Approach

Java

import java.nio.ByteBuffer;

public class ByteBufferisDirect {
    public static void main(String[] args) {

        byte array[] = { 1234 };
        ByteBuffer bb = ByteBuffer.wrap(array);

        System.out.println(bb.isDirect());

    }
}

Output:

false

No comments:

Post a Comment