Source Code : Get URL Parts

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Get URL Parts

      
import java.net.*;

public class GetURLParts {

  public static void main(String args[]) {

      try {
        URL u = new URL("http://www.java2s.com");
        System.out.println("The URL is " + u);
        System.out.println("The protocol part is " + u.getProtocol());
        System.out.println("The host part is " + u.getHost());
        System.out.println("The port part is " + u.getPort());
        System.out.println("The file part is " + u.getFile());
        System.out.println("The ref part is " + u.getRef());
      }  // end try
      catch (MalformedURLException e) {
        System.err.println("not a URL I understand.");
      }

  }  // end main

}  // end getURLParts

           
         
    
    
    
    
    
  

Thank with us