ByteBuffer isReadOnly() in Java

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

Syntax:

boolean java.nio.Buffer.isReadOnly()

This method tells whether or not this buffer is read-only.

Parameters: NA

Returns: true if, and only if, this buffer is read-only.

Exceptions: Na

Approach

Java

import java.nio.ByteBuffer;

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

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

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

    }
}

Output:

false

No comments:

Post a Comment