Implementations of Resource.
This object itself is a Resource uses the current thread's
context class loader.
It also creates Resources with different lookup behavior, using the methods at
, from
, and my
. at
searches
rom a Class, from
searches
from a different ClassLoader,
and my
searches from the class, trait, or object surrounding the call.
Attributes
Members list
Value members
Concrete methods
Look up resource files using the specified ClassLoader.
Look up resource files using the specified ClassLoader.
This Resource looks up resources from a specific ClassLoader. Like the default Resource, resource names are relative to the root package.
Attributes
- cl
ClassLoader to look up resources from.
- Returns:
A Resource that uses the supplied ClassLoader.
- See also:
- Example:
Resource.from(appClassLoader).url("com/example/config.properties")
Inherited methods
Look up a resource by name, and open an InputStream for reading it.
Look up a resource by name, and open an InputStream for reading it.
Attributes
- name
Name of the resource to search for.
- Returns:
InputStream for reading the found resource, if a resource was found.
- See also:
- Inherited from:
- Resource
Attributes
- Inherited from:
- Resource
Look up class resource files.
Look up class resource files.
This Resource looks up resources from the given Class, using
Class#getResource. For example, if
classOf[com.example.ExampleClass]
is given for clazz
, then resource files will be searched for in the com/example
folder
containing ExampleClass.class
.
If you want to look up resource files relative to the call site instead (that is, you want your class to look up one of its own
resources), use the my
method instead.
Attributes
- clazz
The class to look up from.
- Returns:
A Resource for
clazz
.- See also:
- Example:
Resource.at(Class.forName("your.AppClass")).url("config.properties")
In this example, a file named
config.properties
is expected to appear alongside the fileAppClass.class
in the packageyour
.- Inherited from:
- ResourceCompat (hidden)
Look up class resource files.
Look up class resource files.
This Resource looks up resources relative to the JVM class file for T
, using
Class#getResource. For example, if
com.example.ExampleClass
is given for T
, then resource files will be searched for in the com/example
folder containing
ExampleClass.class
.
If you want to look up resource files relative to the call site instead (that is, you want a class to look up one of its own
resources), use the my
method instead.
Attributes
- T
The class, trait, or object to look up from. Objects must be written with a
.type
suffix, such asResource.at[SomeObject.type]
.- Returns:
A Resource for
T
.- See also:
- Example:
Resource.at[YourClass].url("config.properties")
- Inherited from:
- ResourceCompat (hidden)
Same as asStream but throws a NoSuchElementException if resource is not found
Same as asStream but throws a NoSuchElementException if resource is not found
Attributes
- Inherited from:
- Resource
Attributes
- Inherited from:
- Resource
Get URL of given resource A default argument of empty string is provided to conveniently get the root resource URL using {{Resource.getUrl()}}
Get URL of given resource A default argument of empty string is provided to conveniently get the root resource URL using {{Resource.getUrl()}}
Attributes
- Inherited from:
- Resource
Look up own resource files.
Look up own resource files.
This Resource looks up resources from the Class surrounding the
call, using Class#getResource. For
example, if my
is called from com.example.ExampleClass
, then resource files will be searched for in the com/example
folder
containing ExampleClass.class
.
Attributes
- Returns:
A Resource for the call site.
- See also:
- Example:
Resource.my.url("config.properties")
- Inherited from:
- ResourceCompat (hidden)