public final class Locator extends Object
Modifier and Type | Method and Description |
---|---|
static String |
fromURI(String uri)
Constructs a file path from a
file: URI. |
static File |
getClassSource(Class<?> c)
Find the directory or jar file the class has been loaded from.
|
static URL[] |
getLocationURLs(File location)
Get an array or URLs representing all of the jar files in the
given location.
|
static URL[] |
getLocationURLs(File location,
String[] extensions)
Get an array or URLs representing all of the files of a given set of
extensions in the given location.
|
static File |
getResourceSource(ClassLoader c,
String resource)
Find the directory or jar a give resource has been loaded from.
|
static File |
getToolsJar()
Get the File necessary to load the Sun compiler tools.
|
public static File getClassSource(Class<?> c)
c
- the class whose location is required.public static File getResourceSource(ClassLoader c, String resource)
c
- the classloader to be consulted for the sourceresource
- the resource whose location is required.public static String fromURI(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 File getToolsJar()
public static URL[] getLocationURLs(File location) throws MalformedURLException
location
- the location to scan for JarsMalformedURLException
- if the URLs for the jars cannot be
formedpublic static URL[] getLocationURLs(File location, String[] extensions) throws MalformedURLException
location
- the location to scan for filesextensions
- an array of extension that are to match in the
directory searchMalformedURLException
- if the URLs for the files cannot be
formed