code: public static int toShort(byte[] b, int off, boolean littleEndian) {
  		if (littleEndian) {
  			return ((b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8));
  		}
  		return (((b[off] & 0xFF) << 8) | (b[off + 1] & 0xFF));
  	}
docs: Retrieve a <b>short</b> from a byte array in a given byte order