public final class Locator
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
fromURI(java.lang.String uri)
Constructs a file path from a
file: URI. |
static java.io.File |
getClassSource(java.lang.Class<?> c)
Find the directory or jar file the class has been loaded from.
|
static java.net.URL[] |
getLocationURLs(java.io.File location)
Get an array or URLs representing all of the jar files in the
given location.
|
static java.net.URL[] |
getLocationURLs(java.io.File location,
java.lang.String[] extensions)
Get an array or URLs representing all of the files of a given set of
extensions in the given location.
|
static java.io.File |
getResourceSource(java.lang.ClassLoader c,
java.lang.String resource)
Find the directory or jar a give resource has been loaded from.
|
static java.io.File |
getToolsJar()
Get the File necessary to load the Sun compiler tools.
|
public static java.io.File getClassSource(java.lang.Class<?> c)
c
- the class whose location is required.public static java.io.File getResourceSource(java.lang.ClassLoader c, java.lang.String resource)
c
- the classloader to be consulted for the sourceresource
- the resource whose location is required.public static java.lang.String fromURI(java.lang.String uri)
file:
URI.
Will be an absolute path if the given URI is absolute.
Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.
uri
- the URI designating a file in the local filesystem.public static java.io.File getToolsJar()
public static java.net.URL[] getLocationURLs(java.io.File location) throws java.net.MalformedURLException
location
- the location to scan for Jarsjava.net.MalformedURLException
- if the URLs for the jars cannot be
formedpublic static java.net.URL[] getLocationURLs(java.io.File location, java.lang.String[] extensions) throws java.net.MalformedURLException
location
- the location to scan for filesextensions
- an array of extension that are to match in the
directory searchjava.net.MalformedURLException
- if the URLs for the files cannot be
formed