Created
January 19, 2016 09:01
-
-
Save lanetteamkaushal/933f045e79fa43ae6c4b to your computer and use it in GitHub Desktop.
Common codes
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
import java.net.*; | |
import java.io.*; | |
public class ParseURL { | |
public static void main(String[] args) throws Exception { | |
URL aURL = new URL("http://example.com:80/docs/books/tutorial" | |
+ "/index.html?name=networking#DOWNLOADING"); | |
System.out.println("protocol = " + aURL.getProtocol()); //http | |
System.out.println("authority = " + aURL.getAuthority()); //example.com:80 | |
System.out.println("host = " + aURL.getHost()); //example.com | |
System.out.println("port = " + aURL.getPort()); //80 | |
System.out.println("path = " + aURL.getPath()); // /docs/books/tutorial/index.html | |
System.out.println("query = " + aURL.getQuery()); //name=networking | |
System.out.println("filename = " + aURL.getFile()); ///docs/books/tutorial/index.html?name=networking | |
System.out.println("ref = " + aURL.getRef()); //DOWNLOADING | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment