code: public static int toInt(byte[] buf, int off) {
          int lg = (buf[off] & 0xff) << 24;
          lg |= (buf[off+1] & 0xff) << 16;
          lg |= (buf[off+2] & 0xff) << 8;
          lg |= (buf[off+3] & 0xff);
          return lg;
      }
docs: Converts 4 bytes to an <code>int</code> at
  the specified offset in the given byte array.
  
  @param buf the byte array containing the 4 bytes
  to be converted to an <code>int</code>.
  @param off offset in the byte array
  @return the <code>int</code> value of the 4 bytes.