trait Resource extends AnyRef

Finds and loads class resources or class loader resources.

The default implementation of this trait is the Resource object, which looks up resources using the current thread's context class loader. The Resource object also offers several other Resource implementations, through its methods at, from, and my. at searches from a Class, from searches from a ClassLoader, and my searches from the class, trait, or object surrounding the call.

Example:
  1. // Look up the config.properties file for this class or object.
    Resource.my.asStream("config.properties")
    
    // Find logging.properties (in the root package) somewhere on the classpath.
    Resource.url("logging.properties")
See also

Resource

Different ways of loading a file as an InputStream

Class#getResource

ClassLoader#getResource

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Resource
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def url(name: String): Option[URL]

    Look up a resource by name, and get its URL.

    Look up a resource by name, and get its URL.

    name

    Name of the resource to search for.

    returns

    URL of the requested resource. If the resource could not be found or is not accessible, returns None.

    See also

    Class#getResource

    ClassLoader#getResource

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. 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.

    Annotations
    @throws( ... )
    See also

    Class#getResourceAsStream

    ClassLoader#getResourceAsStream

  6. def asString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): Option[String]
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def getAsStream(name: String): InputStream

    Same as asStream but throws a NoSuchElementException if resource is not found

  12. def getAsString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): String
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. 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()}}

  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped