Reputation: 51331
The equals()
method of the URL class in the Java class library makes a DNS request to get the IP for the hostname, to check the two IP's for equality. This happens even for URLs that are created from the same String
. Is there a way to avoid this internet access?
Upvotes: 13
Views: 3111
Reputation: 4763
If you just want to compare the url strings, try
url1.toString().equals(url2.toString())
Upvotes: 4
Reputation: 223173
Don't use URL.equals. As the documentation says,
Note: The defined behavior for
equals
is known to be inconsistent with virtual hosting in HTTP.
Upvotes: 2