HERE IS THE CODE :
-------------------------
import java.net.MalformedURLException;
import java.net.URL;
public class GetHostProperty {
public static void main(String[] args) {
try {
String url =
"https://mail.google.com/mail/?tab=jm&pli=1#inbox/1450ef3ef801473e";
URL myUrl = new URL(url);
System.out.println("Protocol: "+myUrl.getProtocol());
System.out.println("Host: "+myUrl.getHost());
System.out.println("Port: "+myUrl.getPort());
System.out.println("Athority of the URL: "+myUrl.getAuthority());
System.out.println("Query: "+myUrl.getQuery());
System.out.println("Reference: "+myUrl.getRef());
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
}
-------------------------
import java.net.MalformedURLException;
import java.net.URL;
public class GetHostProperty {
public static void main(String[] args) {
try {
String url =
"https://mail.google.com/mail/?tab=jm&pli=1#inbox/1450ef3ef801473e";
URL myUrl = new URL(url);
System.out.println("Protocol: "+myUrl.getProtocol());
System.out.println("Host: "+myUrl.getHost());
System.out.println("Port: "+myUrl.getPort());
System.out.println("Athority of the URL: "+myUrl.getAuthority());
System.out.println("Query: "+myUrl.getQuery());
System.out.println("Reference: "+myUrl.getRef());
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
}
KEEP SHARING KNOWLEDGE
No comments:
Post a Comment