code: protected boolean sameFile(URL u1, URL u2) {
          // Compare the protocols.
          if (!((u1.getProtocol() == u2.getProtocol()) ||
                (u1.getProtocol() != null &&
                 u1.getProtocol().equalsIgnoreCase(u2.getProtocol()))))
              return false;
  
          // Compare the files.
          if (!(u1.getFile() == u2.getFile() ||
                (u1.getFile() != null && u1.getFile().equals(u2.getFile()))))
              return false;
  
          // Compare the ports.
          int port1, port2;
          try {
              port1 = (u1.getPort() != -1)
                  ? u1.getPort() : ((URLStreamHandler) u1.getHandler()).getDefaultPort();
              port2 = (u2.getPort() != -1)
                  ? u2.getPort() : ((URLStreamHandler) u2.getHandler()).getDefaultPort();
              if (port1 != port2)
                  return false;
          } catch (MalformedURLException e) {
              return false;
          }
  
          // Compare the hosts.
          if (!hostsEqual(u1, u2))
              return false;
  
          return true;
      }
docs: Compare two urls to see whether they refer to the same file,
  i.e., having the same protocol, host, port, and path.
  This method requires that none of its arguments is null. This is
  guaranteed by the fact that it is only called indirectly
  by java.net.URL class.
  @param u1 a URL object
  @param u2 a URL object
  @return true if u1 and u2 refer to the same file
  @since 1.3