import java.nio.*; import java.nio.IntBuffer; import java.nio.ByteBuffer; public class IntBufferDemo { public static void main(String[] args) throws Exception { ByteBuffer byteBuffer = ByteBuffer.allocate(1024); int[] array = new int[] { 1, 2, 3, 4 }; IntBuffer IntBuf = byteBuffer.asIntBuffer(); IntBuf.put(array); System.out.println("\nContent of int buffer."); IntBuf.flip(); while (IntBuf.hasRemaining()) { System.out.println(IntBuf.get()); } System.out.println("Position of IntBuffer :" + IntBuf.position()); System.out.println("Limit of IntBuffer :" + IntBuf.limit()); System.out.println("Capacity of IntBuffer :" + IntBuf.capacity()); } }