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

Resource

Different ways of loading a file as an InputStream

Class#getResource

ClassLoader#getResource

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

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.

    Definition Classes
    Resource
    Annotations
    @throws( ... )
    See also

    Class#getResourceAsStream

    ClassLoader#getResourceAsStream

  6. def asString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): Option[String]
    Definition Classes
    Resource
  7. 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 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.

    clazz

    The class to look up from.

    returns

    A Resource for clazz.

    Example:
    1. Resource.at(Class.forName("your.AppClass")).url("config.properties")

      In this example, a file named config.properties is expected to appear alongside the file AppClass.class in the package your.

    See also

    Class#getResource

  8. 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, 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.

    T

    The class, trait, or object to look up from. Objects must be written with a .type suffix, such as Resource.at[SomeObject.type].

    returns

    A Resource for T.

    Example:
    1. Resource.at[YourClass].url("config.properties")
    See also

    Class#getResource

  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. 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.

    Example:
    1. Resource.from(appClassLoader).url("com/example/config.properties")
    See also

    ClassLoader#getResource

  14. 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
  15. def getAsString(name: String, bufferSize: Int = DefaultBufferSize)(implicit charset: Charset = DefaultCharset): String
    Definition Classes
    Resource
  16. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. 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
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. 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 from com.example.ExampleClass, then resource files will be searched for in the com/example folder containing ExampleClass.class.

    returns

    A Resource for the call site.

    Example:
    1. Resource.my.url("config.properties")
    See also

    Class#getResource

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. def notFound(name: String): Nothing
    Annotations
    @throws( ... )
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  26. def toString(): String
    Definition Classes
    AnyRef → Any
  27. 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.

    Definition Classes
    ResourceResource
    See also

    Class#getResource

    ClassLoader#getResource

  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from Resource

Inherited from AnyRef

Inherited from Any

Ungrouped