Java IO Tutorial - Java ByteBuffer.getLong(int index)








Syntax

ByteBuffer.getLong(int index) has the following syntax.

public abstract long getLong(int index)

Example

In the following code shows how to use ByteBuffer.getLong(int index) method.

import java.nio.ByteBuffer;
//from  w ww  .  ja va  2  s  .co  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(0));

  }
}

The code above generates the following result.