public final class ResourceLoader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SYSTEM_RESOURCE_TYPE_FILE |
static java.lang.String |
SYSTEM_RESOURCE_TYPE_GENERIC |
static java.lang.String |
SYSTEM_RESOURCE_TYPE_JAR |
static java.lang.String |
SYSTEM_RESOURCE_TYPE_ZIP |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
formatResourcePath(java.lang.String a_strRelativeResourcePath)
Reformats a given resource name in a way it can be easily interpreted by the resource
loader methods.
|
static java.util.Vector |
getFilesInClassPath() |
static java.net.URL |
getResourceURL(java.lang.String a_strRelativeResourcePath)
Gets the absolute URL to a requested resource if the resource is found in the class path or
in the local directory.
|
static byte[] |
getStreamAsBytes(java.io.InputStream a_iStream)
Reads a java.io.InputStream into a byte array and closes the stream.
|
static byte[] |
loadResource(java.lang.String a_strRelativeResourcePath)
Loads a resource from the classpath or the current directory.
|
static java.io.InputStream |
loadResourceAsStream(java.lang.String a_strRelativeResourcePath)
Loads a resource from the classpath or the current directory.
|
static java.io.InputStream |
loadResourceAsStream(java.lang.String a_strRelativeResourcePath,
boolean a_bFileFirst) |
static java.util.Hashtable |
loadResources(java.lang.String a_strResourceSearchPath,
boolean a_bRecursive)
Loads resources from the classpath or the current directory and instantiates them as
byte arrays.
|
static java.util.Hashtable |
loadResources(java.lang.String a_strResourceSearchPath,
java.io.File a_directory,
boolean a_bRecursive)
Loads resources from a directory and instantiates them as byte arrays.
|
static java.util.Hashtable |
loadResources(java.lang.String a_strResourceSearchPath,
java.io.File a_directory,
IResourceInstantiator a_instantiator,
boolean a_bRecursive)
Loads resources from a directory and instantiates them as
objects of a type defined by the resource instantiator.
|
static java.util.Hashtable |
loadResources(java.lang.String a_strResourceSearchPath,
IResourceInstantiator a_instantiator,
boolean a_bRecursive)
Loads resources from the classpath or the current directory and instantiates them as
objects of a type defined by the resource instantiator.
|
static java.lang.String |
replaceFileSeparatorsSystemSpecific(java.lang.String a_filename)
Interprets a String as a filename and converts its file separators to
system specific file separators.
|
static void |
setReourceLoaderHelper(IResourceLoaderHelper helper) |
public static final java.lang.String SYSTEM_RESOURCE_TYPE_ZIP
public static final java.lang.String SYSTEM_RESOURCE_TYPE_JAR
public static final java.lang.String SYSTEM_RESOURCE_TYPE_FILE
public static final java.lang.String SYSTEM_RESOURCE_TYPE_GENERIC
public static void setReourceLoaderHelper(IResourceLoaderHelper helper)
public static java.util.Vector getFilesInClassPath()
public static byte[] getStreamAsBytes(java.io.InputStream a_iStream) throws java.io.IOException
a_iStream
- an InputStreamjava.io.IOException
- if an I/O error occurspublic static java.net.URL getResourceURL(java.lang.String a_strRelativeResourcePath)
a_strRelativeResourcePath
- the relative path to a resourcepublic static java.io.InputStream loadResourceAsStream(java.lang.String a_strRelativeResourcePath)
a_strRelativeResourcePath
- a relative filename for the resourcepublic static java.io.InputStream loadResourceAsStream(java.lang.String a_strRelativeResourcePath, boolean a_bFileFirst)
public static byte[] loadResource(java.lang.String a_strRelativeResourcePath)
a_strRelativeResourcePath
- a relative filename for the resourcepublic static java.util.Hashtable loadResources(java.lang.String a_strResourceSearchPath, boolean a_bRecursive)
a_strResourceSearchPath
- a relative filename for the resourcea_bRecursive
- true if (virtual) subdirectories should be searched for resources;
false otherwise (has an effect only for resource paths ending with "/")public static java.util.Hashtable loadResources(java.lang.String a_strResourceSearchPath, IResourceInstantiator a_instantiator, boolean a_bRecursive)
a_strResourceSearchPath
- a relative filename for the resourcea_instantiator
- an object that instantiates the loaded resourcea_bRecursive
- true if (virtual) subdirectories should be searched for resources;
false otherwise (has an effect only for resource paths ending with "/")public static java.util.Hashtable loadResources(java.lang.String a_strResourceSearchPath, java.io.File a_directory, boolean a_bRecursive)
a_strResourceSearchPath
- a relative filename for the resourcea_directory
- a simple file, directory or zip filea_bRecursive
- true if (virtual) subdirectories should be searched for resources;
false otherwise (has an effect only for resource paths ending with "/")public static java.util.Hashtable loadResources(java.lang.String a_strResourceSearchPath, java.io.File a_directory, IResourceInstantiator a_instantiator, boolean a_bRecursive)
a_strResourceSearchPath
- a relative filename for the resourcea_directory
- a simple file, directory or zip filea_instantiator
- an object that instantiates the loaded resourcea_bRecursive
- true if (virtual) subdirectories should be searched for resources;
false otherwise (has an effect only for resource paths ending with "/")public static java.lang.String replaceFileSeparatorsSystemSpecific(java.lang.String a_filename)
a_filename
- a generic file namepublic static java.lang.String formatResourcePath(java.lang.String a_strRelativeResourcePath)
a_strRelativeResourcePath
- the relative path to a resourceCopyright © 2023. All rights reserved.