Pin It

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 :


Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot