Trait/Object

better.files

Resource

Related Docs: object Resource | package files

Permalink

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

ClassLoader#getResource

Class#getResource

Different ways of loading a file as an InputStream

Resource

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]

    Permalink

    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

    ClassLoader#getResource

    Class#getResource

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def asStream(name: String): Option[InputStream]

    Permalink

    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

    ClassLoader#getResourceAsStream

    Class#getResourceAsStream

  6. def asString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): Option[String]

    Permalink
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def getAsStream(name: String): InputStream

    Permalink

    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

    Permalink
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def getUrl(name: String = ""): URL

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped