예제 #1
0
  /**
   * Creates the url that we use to announce to the tracker.
   *
   * @param announceURL the announce url
   * @return appended URL with our updated information
   */
  public URL createURL(URL announceURL) {
    String newURL = announceURL.toString();
    newURL +=
        "?info_hash="
            + Utils.toHexString(this.infohash)
            + "&peer_id="
            + Utils.toHexString(this.peerid)
            + "&port="
            + this.port
            + "&uploaded="
            + this.uploaded
            + "&downloaded="
            + this.downloaded
            + "&left="
            + this.left;
    if (this.event != null) newURL += "&event=" + this.event;

    try {
      return new URL(newURL);
    } catch (MalformedURLException e) {
      log.severe("Error: " + e);
      return null;
    }
  }