public final class ResourcesUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
copy(File folder,
String classpathPrefix,
boolean ignoreMissingResources,
String... classpathResources)
Copies classpath resources to real files.
|
static URL |
getResource(String resourceName)
|
static String[] |
list(Class clazz,
String path)
List directory contents for a resource folder.
|
public static void copy(File folder, String classpathPrefix, boolean ignoreMissingResources, String... classpathResources) throws IOException
folder
- to copy resource files intoignoreMissingResources
- if true ignores missing resources, throws IOException otherwiseclasspathPrefix
- common prefix added to all classpath resources which is not used for the result file
path.classpathResources
- list of classpath resources to be copied into folderIOException
public static URL getResource(String resourceName)
URL
pointing to resourceName
if the resource is found using the
context class loader. In simple environments, the
context class loader will find resources from the class path. In environments where different
threads can have different class loaders, for example app servers, the context class loader
will typically have been set to an appropriate loader for the current thread.
In the unusual case where the context class loader is null, the class loader that loaded this class will be used instead.
From Guava.
IllegalArgumentException
- if the resource is not foundpublic static String[] list(Class clazz, String path) throws IOException
clazz
- Any java class that lives in the same place as the resources you want.path
- Should end with "/", but not start with one.IOException
Copyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.