Package org.nd4j.common.resources
Class Resources
- java.lang.Object
-
- org.nd4j.common.resources.Resources
-
public class Resources extends Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedResources()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileasFile(@NonNull String resourcePath)Get the specified resource as a local file.static InputStreamasStream(@NonNull 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.voidcopyDir(String directoryPath, File destinationDir)static voidcopyDirectory(@NonNull String directoryPath, @NonNull File destinationDir)Copy the contents of the specified directory (path) to the specified destination directory, resolving any resources in the processstatic booleanexists(@NonNull String resourcePath)Check if the specified resource exists (can be resolved by any method) hence can be loaded byasFile(String)orasStream(String)protected FilegetAsFile(String resourcePath)InputStreamgetAsStream(String resourcePath)Stringnormalize(String path)static StringnormalizePath(String path)Normalize the path that may be a resource reference.protected booleanresourceExists(String resourcePath)
-
-
-
Method Detail
-
exists
public static boolean exists(@NonNull @NonNull String resourcePath)Check if the specified resource exists (can be resolved by any method) hence can be loaded byasFile(String)orasStream(String)- Parameters:
resourcePath- Path of the resource to be resolved- Returns:
- Whether the resource can be resolved or not
-
asFile
public static File asFile(@NonNull @NonNull String resourcePath)
Get the specified resource as a local file. If it cannot be found (i.e.,exists(String)returns false) this method will throw an exception.- Parameters:
resourcePath- Path of the resource to get- Returns:
- Resource file
-
asStream
public static InputStream asStream(@NonNull @NonNull 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.- Parameters:
resourcePath- Path of the resource to get- Returns:
- Resource stream
-
copyDirectory
public static void copyDirectory(@NonNull @NonNull String directoryPath, @NonNull @NonNull File destinationDir)Copy the contents of the specified directory (path) to the specified destination directory, resolving any resources in the process- Parameters:
directoryPath- Directory to copy contents ofdestinationDir- Destination
-
normalizePath
public static String normalizePath(String path)
Normalize the path that may be a resource reference. For example: "someDir/myFile.zip.resource_reference" --> "someDir/myFile.zip" Returns null if the file cannot be resolved. If the file is not a reference, the original path is returned
-
resourceExists
protected boolean resourceExists(String resourcePath)
-
getAsStream
public InputStream getAsStream(String resourcePath)
-
-