java program
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()); } }
Output
URL is http://www.server.com
protocol is TCP/IP
file name is java_program.txt
host is 122.45.2.36
path is
port is 2
default port is 1
- Implementation of MD5 Algorithm in Java
- Implementation of RSA Algorithm(Encryption and Decryption) in Java
- java program to get the date of URL connection
- java program to read and download a webpage
- java program to find hostname from IP Address
- java program to determine IP Address & hostname of Local Computer?
- java program to check whether a port is being used or not
- java program to find proxy settings of a System
- java program to create a socket at a specific port
- java program to get the parts of an URL