Object/Trait

better.files

Resource

Related Docs: trait Resource | package files

Permalink

object Resource extends Resource with ResourceScalaCompat

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

ClassLoader#getResource

Class#getResource

Different ways of loading a file as an InputStream

Resource

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

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.

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

    ClassLoader#getResourceAsStream

    Class#getResourceAsStream

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

    Permalink
    Definition Classes
    Resource
  7. macro def at(clazz: Class[_]): Resource

    Permalink

    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.

    Definition Classes
    ResourceScalaCompat
    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

    Permalink

    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.

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

    Class#getResource

  9. def clone(): AnyRef

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

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def from(cl: ClassLoader): Resource

    Permalink

    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

    Permalink

    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

    Permalink
    Definition Classes
    Resource
  16. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  17. 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()}}

    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

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

    Permalink
    Definition Classes
    Any
  20. macro def my: Resource

    Permalink

    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.

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

    Class#getResource

  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. def notFound(name: String): Nothing

    Permalink
    Annotations
    @throws( ... )
  23. final def notify(): Unit

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  27. 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.

    Definition Classes
    ResourceResource
    See also

    ClassLoader#getResource

    Class#getResource

  28. final def wait(): Unit

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

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

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

Inherited from ResourceScalaCompat

Inherited from Resource

Inherited from AnyRef

Inherited from Any

Ungrouped