Java IO Tutorial - Java DoubleBuffer .asReadOnlyBuffer ()








Syntax

DoubleBuffer.asReadOnlyBuffer() has the following syntax.

public abstract DoubleBuffer asReadOnlyBuffer()

Example

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

import java.nio.DoubleBuffer;
import java.util.Arrays;
/*from   www.  ja v  a 2s  . com*/
public class Main {
  private static final int BSIZE = 1024;

  public static void main(String[] args) {
    DoubleBuffer bb = DoubleBuffer.allocate(BSIZE);

    bb.put(98765);
    
    DoubleBuffer bb1 = bb.asReadOnlyBuffer();
    
    System.out.println(bb1.toString());

  }
}

The code above generates the following result.