Java IO Tutorial - Java ByteBuffer.asIntBuffer()








Syntax

ByteBuffer.asIntBuffer() has the following syntax.

public abstract IntBuffer asIntBuffer()

Example

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

import java.nio.ByteBuffer;
//from   w  ww  .  j  a  va 2s  .c  om
public class Main {
  private static final int BSIZE = 1024;

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

The code above generates the following result.