Create a URL that refers to a jar file in the file system in Java

Description

The following code shows how to create a URL that refers to a jar file in the file system.

Example


// w w w .j a  v a2  s  .c  om
import java.net.URL;

public class Main {
  public static void main(String[] argv) throws Exception {
    URL url = new URL("jar:file:/c://my.jar!/");
    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