Java java.nio buffers let you specify content.
See http://download.oracle.com/javase/6/docs/api/java/nio/ByteBuffer.html , especially the order method, which allows you to specify endianness and the getInt method, which allows you to read int.
To read a file using ByteBuffer , follow these steps:
ByteBuffer buffer = new RandomAccessFile(myFile, "r") .getChannel.map(MapMode.READ, offset, length);
Remember to close it when done.
source share