Last active
April 18, 2016 05:22
-
-
Save peterkir/87d02e8d90e95eea95b6 to your computer and use it in GitHub Desktop.
java.net.URL obstacles with URL.equals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package issue.java.net.url; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.LinkedHashSet; | |
import java.util.Set; | |
public class CanonicalURLs { | |
public static void main(String[] args) { | |
try { | |
Set<URL> set = new LinkedHashSet<>(); | |
set.add(new URL("http://peterkir.github.io/")); | |
set.add(new URL("http://square.github.io/")); | |
set.add(new URL("http://Square.GitHub.io/")); | |
set.add(new URL("http://square.github.io:80/")); | |
set.add(new URL("http://google.github.io/")); | |
System.out.println(set); // prints only "http://peterkir.github.io/" | |
} catch (MalformedURLException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output is only the following (cause they are the same for Java)
[http://peterkir.github.io/]