/** * Read a 32-bit signed int, in little-endian binary format. * * @param dis stream to read from. * * @return binary value. */ static int readIntLittleEndian( DataInputStream dis ) throws IOException { // clever version // get 2 bytes pieces // unsigned 0..255 int low = dis.readByte() & 0xff; // signed -128 .. 127 int high = dis.readByte(); // avoid masking here, signed result return(short)( high << 8 | low ); }