code: private int bytesToInt(byte[] bytes)
      {
          int result = -1;
          if (bytes.length >= 4)
          {
              result = ((bytes[0]&0xff) << 24) +
                       ((bytes[1]&0xff) << 16) +
                       ((bytes[2]&0xff) << 8) +
                       (bytes[3]&0xff);
          }
          return result;
      }
docs: A helper function which extracts an int from a byte array representation