programming-examples/java/Numerical_Problems/java program to get the parts of an URL.java

14 lines
586 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
import java.net.URL;
public class Main {
public static void main(String[] args)
throws Exception {
URL url = new URL(args[0]);
System.out.println("URL is " + url.toString());
System.out.println("protocol is " + url.getProtocol());
System.out.println("file name is " + url.getFile());
System.out.println("host is " + url.getHost());
System.out.println("path is " + url.getPath());
System.out.println("port is " + url.getPort());
System.out.println("default port is " + url.getDefaultPort());
}
}