public class

URLClassPath

extends Object
java.lang.Object
   ↳ sun.misc.URLClassPath

Class Overview

This class is used to maintain a search path of URLs for loading classes and resources from both JAR files and directories.

Summary

Public Constructors
URLClassPath(URL[] urls, URLStreamHandlerFactory factory)
Creates a new URLClassPath for the given URLs.
URLClassPath(URL[] urls)
Public Methods
void addURL(URL url)
Appends the specified URL to the search path of directory and JAR file URLs from which to load classes and resources.
URL checkURL(URL url)
URL findResource(String name, boolean check)
Finds the resource with the specified name on the URL search path or null if not found or security check fails.
Enumeration findResources(String name, boolean check)
Finds all resources on the URL search path with the given name.
Resource getResource(String name)
Resource getResource(String name, boolean check)
Finds the first Resource on the URL search path which has the specified name.
Enumeration getResources(String name, boolean check)
Finds all resources on the URL search path with the given name.
Enumeration getResources(String name)
URL[] getURLs()
Returns the original search path of URLs.
static URL[] pathToURLs(String path)
Convert class path specification into an array of file URLs.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public URLClassPath (URL[] urls, URLStreamHandlerFactory factory)

Creates a new URLClassPath for the given URLs. The URLs will be searched in the order specified for classes and resources. A URL ending with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file.

Parameters
urls the directory and JAR file URLs to search for classes and resources
factory the URLStreamHandlerFactory to use when creating new URLs

public URLClassPath (URL[] urls)

Public Methods

public void addURL (URL url)

Appends the specified URL to the search path of directory and JAR file URLs from which to load classes and resources.

public URL checkURL (URL url)

public URL findResource (String name, boolean check)

Finds the resource with the specified name on the URL search path or null if not found or security check fails.

Parameters
name the name of the resource
check whether to perform a security check
Returns
  • a URL for the resource, or null if the resource could not be found.

public Enumeration findResources (String name, boolean check)

Finds all resources on the URL search path with the given name. Returns an enumeration of the URL objects.

Parameters
name the resource name
Returns
  • an Enumeration of all the urls having the specified name

public Resource getResource (String name)

public Resource getResource (String name, boolean check)

Finds the first Resource on the URL search path which has the specified name. Returns null if no Resource could be found.

Parameters
name the name of the Resource
check whether to perform a security check
Returns
  • the Resource, or null if not found

public Enumeration getResources (String name, boolean check)

Finds all resources on the URL search path with the given name. Returns an enumeration of the Resource objects.

Parameters
name the resource name
Returns
  • an Enumeration of all the resources having the specified name

public Enumeration getResources (String name)

public URL[] getURLs ()

Returns the original search path of URLs.

public static URL[] pathToURLs (String path)

Convert class path specification into an array of file URLs. The path of the file is encoded before conversion into URL form so that reserved characters can safely appear in the path.