code: static public long bytesToLong(byte[] buffer, int index) {
          int length = buffer.length - index;
          if (length > 8) length = 8;
          long l = 0;
          for (int i = 0; i < length; i++) {
              l |= ((buffer[index + length - i - 1] & 0xFFL) << (i * 8));
          }
          return l;
      }
docs: This function converts the bytes in a byte array at the specified index to its
  corresponding long value.
  
  @param buffer The byte array containing the long.
  @param index The index for the first byte in the byte array.
  @return The corresponding long value.