import java.nio.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; public class ArrayToBuffer { public static void main(String[] arg){ ByteBuffer b = ByteBuffer.allocateDirect(512); IntBuffer iBuffer = b.asIntBuffer(); int[] array = new int[] { 2, 3, 4, 5 }; for (int s = 0; s < array.length; s++) { iBuffer.put(array[s]); } iBuffer.flip(); System.out.println("Content of buffer."); while (iBuffer.hasRemaining()) { System.out.println(iBuffer.get()); } } }