Java program for Uniform Resource Locator (URL)

Program : Uniform Resource Locator (URL)
By : Kapil Lohia

import java.net.*;
import java.io.*;
 
class url
{
	public static void main(String args[]) throws Exception
	{
		URL n1 = new URL("http://java.sun.com:80/docs/index#down");
		System.out.println("Protocol:"+n1.getProtocol());
		System.out.println("Host :"+n1.getHost());
		System.out.println("File Name :"+n1.getFile());
		System.out.println("Port :"+n1.getPort());
		System.out.println("Reference :"+n1.getRef());
	}
}

Leave a Reply