Java LongBuffer.asReadOnlyBuffer()

Syntax

LongBuffer.asReadOnlyBuffer() has the following syntax.

public abstract LongBuffer asReadOnlyBuffer()

Example

In the following code shows how to use LongBuffer.asReadOnlyBuffer() method.


//  ww w  .ja  v a2  s .co  m
import java.nio.LongBuffer;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    LongBuffer longBuffer = LongBuffer.allocate(10);
    longBuffer.put(100);
    
    longBuffer.rewind();
    
    
    LongBuffer longBuffer2 = longBuffer.asReadOnlyBuffer();
    
    System.out.println(Arrays.toString(longBuffer2.array()));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer