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