Resource

better.files.Resource
See theResource companion object
trait Resource

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.

Attributes

See also:
Example:
        // 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")
Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Resource.type

Members list

Concise view

Value members

Abstract methods

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.

Attributes

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:

Concrete methods

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.

Attributes

name

Name of the resource to search for.

Returns:

InputStream for reading the found resource, if a resource was found.

See also:
def asString(name: String, bufferSize: Int, charset: Charset): Option[String]
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

Attributes

def getAsString(name: String, bufferSize: Int, charset: Charset): String
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()}}

Attributes