Program to demonstrate working of URL class and the methods of the URL class for Java Networking
Output of the program :
package com.hubberspot.networking.example;
import java.net.*;
public class URLExample
{
public static void main(String args[])
throws MalformedURLException
{
URL url = new URL ("http://www.hubberspot.com/" +
"p/introduction-to-java.html");
System.out.println("Protocol is:" + url.getProtocol());
System.out.println("Port is:" + url.getPort());
System.out.println("Host is:" + url.getHost());
System.out.println("File is:" + url.getFile());
}
}
Output of the program :
