object Resource extends Resource
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.
- See also
- Alphabetic
- By Inheritance
- Resource
- Resource
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asStream(name: String): Option[InputStream]
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.
- name
Name of the resource to search for.
- returns
InputStream for reading the found resource, if a resource was found.
- Definition Classes
- Resource
- Annotations
- @throws( ... )
- See also
-
def
asString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): Option[String]
- Definition Classes
- Resource
-
macro
def
at(clazz: Class[_]): 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 forclazz
, then resource files will be searched for in thecom/example
folder containingExampleClass.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.- clazz
The class to look up from.
- returns
A Resource for
clazz
.
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
.- See also
Example: -
macro
def
at[T]: Resource
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, ifcom.example.ExampleClass
is given forT
, then resource files will be searched for in thecom/example
folder containingExampleClass.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.- 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
.
Resource.at[YourClass].url("config.properties")
- See also
Example: -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
from(cl: ClassLoader): Resource
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.
- cl
ClassLoader to look up resources from.
- returns
A Resource that uses the supplied ClassLoader.
Resource.from(appClassLoader).url("com/example/config.properties")
- See also
Example: -
def
getAsStream(name: String): InputStream
Same as asStream but throws a NoSuchElementException if resource is not found
Same as asStream but throws a NoSuchElementException if resource is not found
- Definition Classes
- Resource
-
def
getAsString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): String
- Definition Classes
- Resource
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getUrl(name: String = ""): URL
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()}}
- Definition Classes
- Resource
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
macro
def
my: 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 fromcom.example.ExampleClass
, then resource files will be searched for in thecom/example
folder containingExampleClass.class
.- returns
A Resource for the call site.
Resource.my.url("config.properties")
- See also
Example: -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
notFound(name: String): Nothing
- Annotations
- @throws( ... )
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
url(name: String): Option[URL]
Look up a resource by name, and get its URL.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()