Check URL Equality in Java
Description
The following code shows how to check URL Equality.
Example
/*www . ja va 2 s . c o m*/
import java.net.MalformedURLException;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception{
URL ibiblio = new URL("http://www.google.com/");
URL metalab = new URL("http://www.google.ca/");
if (ibiblio.equals(metalab)) {
System.out.println(ibiblio + " is the same as " + metalab);
} else {
System.out.println(ibiblio + " is not the same as " + metalab);
}
}
}
The code above generates the following result.