Java IO Tutorial - Java ByteBuffer.getLong()








Syntax

ByteBuffer.getLong() has the following syntax.

public abstract long getLong()

Example

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

import java.nio.ByteBuffer;
//from  ww  w. ja v  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);
    bb.rewind();
    System.out.println(bb.getLong());

  }
}

The code above generates the following result.