Created
September 23, 2012 15:41
-
-
Save DavyLandman/3772075 to your computer and use it in GitHub Desktop.
URI encoding stuff in Java
This file contains hidden or 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
project://name/path | |
auth: name host: name port: -1 | |
project://name%20space/path | |
auth: name space host: null port: -1 | |
project://name:200/path | |
auth: name:200 host: name port: 200 | |
project://name%20space:200/path | |
auth: name space:200 host: null port: -1 |
This file contains hidden or 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
private static void printInfo(URI u) { | |
System.out.println(u.toString()); | |
System.out.printf("\tauth: %-20s host: %-20s port: %d\n\n", u.getAuthority(), u.getHost(), u.getPort()); | |
} | |
public static void main(String[] args) throws URISyntaxException { | |
printInfo(new URI("project","name","/path", null, null)); | |
printInfo(new URI("project","name space","/path", null, null)); | |
printInfo(new URI("project","name:200","/path", null, null)); | |
printInfo(new URI("project","name space:200","/path", null, null)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment