public class ResourceUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static Set<String> |
libRegistry |
| Modifier and Type | Method and Description |
|---|---|
static File |
extractResource(String resourceId)
Same as getClass().getResource(), but returns a
File handle to an extracted file copy. |
static File |
getResFileUnchecked(Class<?> resourceClass,
String resourceId)
Get a
File to a resource. |
static File |
getResFileUnchecked(String resourceId)
Get a
File to a resource. |
static void |
loadLibrary(String libName)
Loads native libraries from the classpath.
|
static void |
loadLibrary(String libName,
boolean deleteOnExit) |
public static void loadLibrary(String libName)
Platform.RESOURCE_PREFIX. Strictly loads libraries from
the classpath. Ignores jni.library.path setting. This function will detect repeated loads of the same
library and silently skip any further loads using the same libName argument.libName - the native library to load, ie. "fann" for "libfann.so" on Linux systemsRuntimeException - checked exception are wrapped in RuntimeExceptionpublic static void loadLibrary(String libName, boolean deleteOnExit)
libName - the native library to load, ie. "fann" for "libfann.so" on Linux systemsdeleteOnExit - if true, delete unpacked library on VM exit, not beforeRuntimeException - checked exception are wrapped in RuntimeExceptionloadLibrary(String)public static File extractResource(String resourceId) throws IOException
File handle to an extracted file copy.
Beware: it's your duty to clean up this file, though it's created inside your system's temp folder.resourceId - an absolute resourceId (ie. starts with "/")IOException - if there was an I/O problempublic static File getResFileUnchecked(String resourceId)
File to a resource. Because you don't give this method a class, only
absolute resource IDs are usually sensible choices. This function only works for
extracted resources, not for resource packed inside jars. The function will throw only unchecked
exceptions and is mainly useful for static initializers and test units.resourceId - the resource path, preferably an absolute onepublic static File getResFileUnchecked(Class<?> resourceClass, String resourceId)
File to a resource. The resourceId argument can be relative, it will be resolved
relative to the resourceClass argument. This function only works for
extracted resources, not for resource packed inside jars. The function will throw only unchecked
exceptions and is mainly useful for static initializers and test units.resourceClass - the classresourceId - the resource path, sensibly a relative oneCopyright © 2014–2017 Github jjYBdx4IL Projects. All rights reserved.