/** * Read a 16-bit signed short, in little-endian binary format. * * @param dis stream to read from. * * @return binary value. */ static short readShortLittleEndian( DataInputStream dis ) throws IOException { // get 2 bytes, unsigned 0..255 int low = dis.readByte() & 0xff; int high = dis.readByte() & 0xff; // combine into a signed short. return ( short ) ( high << 8 | low ); // rem in JDK 1.5+ you can say: // return Short.reverseBytes( s ); }