Create a URL With components in Java

Description

The following code shows how to create a URL With components.

Example


     /*from w  w  w.  j a  va2 s .  co  m*/

import java.net.URL;

public class Main {
  public static void main(String[] argv) throws Exception {

    URL url = new URL("http", "hostname", 80, "index.html");
    System.out.println(url);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode