public class ResourceUtils extends Object
| Constructor and Description |
|---|
ResourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Path |
getResourcePath(Class<?> clazz,
String relPath)
Find the path to a resource relative to the location of class c.
|
static URI |
getResourceUri(Class<?> clazz,
String relPath)
Finds the URI for a resource relative to a specified class.
|
static boolean |
isInsideJar(Class<?> clazz)
Determines if the specified class was loaded from
a JAR file or a .class file in the file system.
|
static Path[] |
listResources(Class<?> clazz,
String relPath)
Use this method to obtain the paths to all files in a directory located
relative to the specified class.
|
static Path[] |
listResources(Path path)
Method to obtain the paths to all files in a directory specified
by a path.
|
static Path[] |
listResources(URI uri) |
static ij.ImagePlus |
openImageFromResource(Class<?> clazz,
String resDir,
String resName)
Opens an image from the specified resource.
|
static Path |
uriToPath(URI uri)
Converts an URI to a Path for locations that are either
in the file system or inside a JAR file.
|
public ResourceUtils()
public static boolean isInsideJar(Class<?> clazz)
clazz - the classpublic static URI getResourceUri(Class<?> clazz, String relPath)
clazz - the anchor classrelPath - the resource path relative to the anchor classnull if the resource was not foundpublic static Path getResourcePath(Class<?> clazz, String relPath)
clazz - anchor classrelPath - the path of the resource to be found (relative to the location of the anchor class)public static Path uriToPath(URI uri)
uri - the specified locationpublic static Path[] listResources(URI uri)
public static Path[] listResources(Path path)
path - path to a directory (may be contained in a JAR file)null if the specified path
is not a directorypublic static Path[] listResources(Class<?> clazz, String relPath)
clazz - class whose source location specifies the rootrelPath - path relative to the rootnull if the specified path is not a directorypublic static ij.ImagePlus openImageFromResource(Class<?> clazz, String resDir, String resName)
Opener class.clazz - the anchor classresDir - the directory relative to the anchor classresName - the (file) name of the image resourcenull if not successful.Copyright © 2006–2017, Wilhelm Burger, Mark J. Burge (BSD 2-Clause Simplified License)