code: protected boolean hostsEqual(URL u1, URL u2) {
          /*
           * Special case for file: URLs
           * per RFC 1738 no hostname is equivalent to 'localhost'
           * i.e. file:///path is equal to file://localhost/path
           */
          String s1 = u1.getHost();
          String s2 = u2.getHost();
          if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2)))
              return true;
          if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1)))
              return true;
          return super.hostsEqual(u1, u2);
      }
docs: Compares the host components of two URLs.
  @param u1 the URL of the first host to compare
  @param u2 the URL of the second host to compare
  @return  <tt>true</tt> if and only if they
  are equal, <tt>false</tt> otherwise.