Java IO Tutorial - Java ByteBuffer.asLongBuffer()








Syntax

ByteBuffer.asLongBuffer() has the following syntax.

public abstract LongBuffer asLongBuffer()

Example

In the following code shows how to use ByteBuffer.asLongBuffer() method.

import java.nio.ByteBuffer;
//from w  w  w.  j  av  a2  s .c o m
public class Main {
  private static final int BSIZE = 1024;

  public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);
    bb.asLongBuffer().put(99472342341142L);
    System.out.println(bb.getLong());

  }
}

The code above generates the following result.