|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.arakhne.vmutil.Resources
public class Resources
This utility class provides to load resources according to several heuristics:
| Field Summary | |
|---|---|
static String |
NAME_SEPARATOR
Character used to separate paths on an resource name. |
| Constructor Summary | |
|---|---|
Resources()
|
|
| Method Summary | |
|---|---|
static URL |
getPropertyFile(Class<?> classname,
Locale locale)
Replies the URL of a property resource that is associated to the given class. |
static URL |
getPropertyFile(ClassLoader classLoader,
Class<?> classname,
Locale locale)
Replies the URL of a property resource that is associated to the given class. |
static URL |
getResource(Class<?> classname,
String path)
Replies the URL of a resource. |
static URL |
getResource(ClassLoader classLoader,
Package packagename,
String path)
Replies the URL of a resource. |
static URL |
getResource(ClassLoader classLoader,
String path)
Replies the URL of a resource. |
static URL |
getResource(String path)
Replies the URL of a resource. |
static InputStream |
getResourceAsStream(Class<?> classname,
String path)
Replies the input stream of a resource. |
static InputStream |
getResourceAsStream(ClassLoader classLoader,
Package packagename,
String path)
Replies the input stream of a resource. |
static InputStream |
getResourceAsStream(ClassLoader classLoader,
String path)
Replies the input stream of a resource. |
static InputStream |
getResourceAsStream(String path)
Replies the input stream of a resource. |
static String |
translateResourceName(String resourceName)
Translate the given resource name according to the current JVM standard. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String NAME_SEPARATOR
| Constructor Detail |
|---|
public Resources()
| Method Detail |
|---|
public static URL getResource(String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
The class loader replied by ClassLoaderFinder is used.
If it is null, the class loader of
the Resources class is used.
path - is the absolute path of the resource.
null if the resource was
not found in class paths.
public static URL getResource(ClassLoader classLoader,
Package packagename,
String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
The name of packagename is translated into a resource path (by replacing the dots by slashes) and the given path is append to. For example, the two following codes are equivalent:
Resources.getResources(Package.getPackage("org.arakhne.afc"), "/a/b/c/d.png");
Resources.getResources("org/arakhne/afc/a/b/c/d.png");
If the classLoader parameter is null,
the class loader replied by ClassLoaderFinder is used.
If this last is null, the class loader of
the Resources class is used.
classLoader - is the research scope. If null,
the class loader replied by ClassLoaderFinder is used.packagename - is the package in which the resource should be located.path - is the relative path of the resource in the package.
null if the resource was
not found in class paths.
public static URL getResource(Class<?> classname,
String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
The name of classname is translated into a resource path (by remove the name of the class and replacing the dots by slashes) and the given path is append to. For example, the two following codes are equivalent:
Resources.getResources(Resources.class, "/a/b/c/d.png");
Resources.getResources("org/arakhne/vmutil/a/b/c/d.png");
The class loader of the given class is used. If it is null,
the class loader replied by ClassLoaderFinder is used.
If it is also null, the class loader of this Resources
class is used.
classname - is located in the package in which the resource should be also located.path - is the absolute path of the resource.
null if the resource was
not found in class paths.
public static URL getResource(ClassLoader classLoader,
String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
If the classLoader parameter is null,
the class loader replied by ClassLoaderFinder is used.
If this last is null, the class loader of
the Resources class is used.
classLoader - is the research scope. If null,
the class loader replied by ClassLoaderFinder is used.path - is the absolute path of the resource.
null if the resource was
not found in class paths.public static InputStream getResourceAsStream(String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames, and may not start the path with a slash.
The class loader replied by ClassLoaderFinder is used.
If it is null, the class loader of
the Resources class is used.
path - is the absolute path of the resource.
null if the resource was
not found in class paths.
public static InputStream getResourceAsStream(ClassLoader classLoader,
Package packagename,
String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
The name of packagename is translated into a resource path (by replacing the dots by slashes) and the given path is append to. For example, the two following codes are equivalent:
Resources.getResources(Package.getPackage("org.arakhne.afc"), "/a/b/c/d.png");
Resources.getResources("org/arakhne/afc/a/b/c/d.png");
If the classLoader parameter is null,
the class loader replied by ClassLoaderFinder is used.
If this last is null, the class loader of
the Resources class is used.
classLoader - is the research scope. If null,
the class loader replied by ClassLoaderFinder is used.packagename - is the package in which the resource should be located.path - is the relative path of the resource in the package.
null if the resource was
not found in class paths.
public static InputStream getResourceAsStream(Class<?> classname,
String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
The name of classname is translated into a resource path (by remove the name of the class and replacing the dots by slashes) and the given path is append to. For example, the two following codes are equivalent:
Resources.getResources(Resources.class, "/a/b/c/d.png");
Resources.getResources("org/arakhne/vmutil/a/b/c/d.png");
The class loader of the given class is used. If it is null,
the class loader replied by ClassLoaderFinder is used.
If it is also null, the class loader of this Resources
class is used.
classname - is located in the package in which the resource should be also located.path - is the absolute path of the resource.
null if the resource was
not found in class paths.
public static InputStream getResourceAsStream(ClassLoader classLoader,
String path)
You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames, and may not start the path with a slash.
If the classLoader parameter is null,
the class loader replied by ClassLoaderFinder is used.
If this last is null, the class loader of
the Resources class is used.
classLoader - is the research scope. If null,
the class loader replied by ClassLoaderFinder is used.path - is the absolute path of the resource.
null if the resource was
not found in class paths.
public static URL getPropertyFile(Class<?> classname,
Locale locale)
classname - is the class for which the property resource should be replied.locale - is the expected localization of the resource file; or null
for the default.
null if the resource was
not found in class paths.
public static URL getPropertyFile(ClassLoader classLoader,
Class<?> classname,
Locale locale)
classLoader - is the research scope. If null,
the class loader replied by ClassLoaderFinder is used.classname - is the class for which the property resource should be replied.locale - is the expected localization of the resource file; or null
for the default.
null if the resource was
not found in class paths.public static String translateResourceName(String resourceName)
The resourceName argument should be a fully
qualified class name. However, for compatibility with earlier
versions, Sun's Java SE Runtime Environments do not verify this,
and so it is possible to access PropertyResourceBundles
by specifying a path name (using "/") instead of a fully
qualified class name (using ".").
In several VM, such as Dalvik, the translation from "." to "/" is not
automatically done by the VM to retreive the file.
resourceName -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||