Java LongBuffer compare with ByteBuffer for byte content
import java.nio.ByteBuffer; import java.nio.LongBuffer; public class Main { public static void main(String[] args) { ByteBuffer bb = ByteBuffer.wrap(new byte[] { 0, 0, 0, 0, 0, 0, 0, 'a' }); bb.rewind();/*from w w w. j av a 2 s . c o m*/ System.out.println("Byte Buffer"); while (bb.hasRemaining()) System.out.println(bb.position() + " -> " + bb.get()); LongBuffer lb = ((ByteBuffer) bb.rewind()).asLongBuffer(); System.out.println("Long Buffer"); while (lb.hasRemaining()) System.out.println(lb.position() + " -> " + lb.get()); } }