Java IO Tutorial - Java ByteBuffer.getInt()








Syntax

ByteBuffer.getInt() has the following syntax.

public abstract int getInt()

Example

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

//from   w w w.j  a v a 2  s .  co  m
import java.nio.ByteBuffer;

public class Main {
  private static final int BSIZE = 1024;

  public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);
    bb.asIntBuffer().put(99471142);
    bb.rewind();
    System.out.println(bb.getInt());
  }
}

The code above generates the following result.