Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package url;
- import java.util.*;
- import java.net.URL;
- public class Url {
- public static void main(String[] args) {
- try{
- URL u = new URL("https://www.example.com/path/to/file.html?key=value#fragment");
- System.out.println("Protocol : "+u.getProtocol());
- System.out.println("Port : "+u.getPort());
- System.out.println("Path : "+u.getPath());
- System.out.println("Host : "+u.getHost());
- System.out.println("Query : "+u.getQuery());
- System.out.println("Fragmnet : "+u.getRef());
- }
- catch(Exception e){
- System.out.println("Error "+ e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment