import java.nio.*; import java.nio.LongBuffer; import java.nio.ByteBuffer; public class LongByByteBuffer { public static void main(String[] args) throws Exception { ByteBuffer byteBuf=ByteBuffer.allocate(1024); LongBuffer longBuf =byteBuf.asLongBuffer(); long[] array = new long[] {6545555, 787867}; longBuf.put(array); longBuf.flip(); System.out.println("Content in long buffer."); while (longBuf.hasRemaining()) { System.out.println(longBuf.get()); } System.out.println("Capacity of LongBuffer : " + longBuf.capacity()); System.out.println("Limit of LongBuffer : " + longBuf.limit()); System.out.println("Position of LongBuffer : " + longBuf.position()); } }