public class Resources
extends java.lang.Object
instances this class cas be used to
resolve files on the classpath, or reference files (referring to a remote file that needs to be downloaded).StrumpfResolver is used, but others can be added using the Java ServiceLoader mechanism
for Resolver class.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Resolver> |
resolvers |
| Modifier | Constructor and Description |
|---|---|
protected |
Resources() |
| Modifier and Type | Method and Description |
|---|---|
static java.io.File |
asFile(java.lang.String resourcePath)
Get the specified resource as a local file.
|
static java.io.InputStream |
asStream(java.lang.String resourcePath)
Get the specified resource as an input stream.
If it cannot be found (i.e., exists(String) returns false) this method will throw an exception. |
void |
copyDir(java.lang.String directoryPath,
java.io.File destinationDir) |
static void |
copyDirectory(java.lang.String directoryPath,
java.io.File destinationDir)
Copy the contents of the specified directory (path) to the specified destination directory, resolving any resources in the process
|
static boolean |
exists(java.lang.String resourcePath)
Check if the specified resource exists (can be resolved by any method) hence can be loaded by
asFile(String)
or asStream(String) |
protected java.io.File |
getAsFile(java.lang.String resourcePath) |
java.io.InputStream |
getAsStream(java.lang.String resourcePath) |
protected boolean |
resourceExists(java.lang.String resourcePath) |
protected final java.util.List<Resolver> resolvers
public static boolean exists(@NonNull
java.lang.String resourcePath)
asFile(String)
or asStream(String)resourcePath - Path of the resource to be resolvedpublic static java.io.File asFile(@NonNull
java.lang.String resourcePath)
exists(String) returns false) this method will throw an exception.resourcePath - Path of the resource to getpublic static java.io.InputStream asStream(@NonNull
java.lang.String resourcePath)
exists(String) returns false) this method will throw an exception.resourcePath - Path of the resource to getpublic static void copyDirectory(@NonNull
java.lang.String directoryPath,
@NonNull
java.io.File destinationDir)
directoryPath - Directory to copy contents ofdestinationDir - Destinationprotected boolean resourceExists(java.lang.String resourcePath)
protected java.io.File getAsFile(java.lang.String resourcePath)
public java.io.InputStream getAsStream(java.lang.String resourcePath)
public void copyDir(java.lang.String directoryPath,
java.io.File destinationDir)
Copyright © 2019. All rights reserved.