Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe to all free courses

How to use java.net.URL Class for Java Networking ?.

Program to demonstrate working of URL class and the methods of the URL class for Java Networking

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 :


 
© 2021 Learn Java by Examples Template by Hubberspot