In Java, comparing two URLs for equality does I/O. *facepalm* See for yourself: http://docs.oracle.com/javase...
So does hashCode, of course.
- Tudor Bosman
I'm sure it's useful for something... I guess don't use URL.equals(), if you don't need the full response checking?
- OCoG of FF, Jimminy
It's nice to be able to check that you're looking at the same object, regardless of the string representation of the URL. An example, 127.0.0.1/file/x.html equals localhost/file/x.html. Though I'm sure there are some extremely rare edge cases where the IP that responds isn't a match.
- OCoG of FF, Jimminy
Jimminy, even that may not be good all the time. Lets say we convert the name to an IP and even eliminate the protocol (http vs https). Still there are cases that your equals method would fail. One example is when a domain has multiple IP addresses. Another is when a server is not a dedicated server and hosts multiple domains. In that case, a URI of a domain could falsely match with a URI of another domain.
- ؛ patrick
If A redirects to B are they equal?
- Bruce Lewis
I don't know, I'd assume a simple 301 or 302 would be followed, within reasonable depth. But I haven't touched Java in a long time.
- OCoG of FF, Jimminy
It's not actually clear from a skim. http://www.docjar.com/html...
- OCoG of FF, Jimminy
:(
- Amit Patel