Resource

object Resource

Resource file manager.

Resource file manager.

Authors

leo

class Object
trait Matchable
class Any

Type members

Classlikes

case class FileInJar(resourceURL: URL, logicalPath: String, isDirectory: Boolean) extends VirtualFile

A virtual file implementation for file resources contained in a JAR file

A virtual file implementation for file resources contained in a JAR file

Authors

leo

case class SystemFile(file: File, logicalPath: String) extends VirtualFile

A virtual file implementation for usual files

A virtual file implementation for usual files

Authors

leo

abstract trait VirtualFile

VirtualFile is a common interface to handle system files and file resources in JAR.

VirtualFile is a common interface to handle system files and file resources in JAR.

System file resources have an URL prefixed with "file:". e.g., "file:/C:/Program Files/Software/classes/org/xerial/util/FileResource.java" JAR file contents have an URL prefixed with "jar:file: e.g., "jar:file:/C:/Program Files/Software/something.jar!/org/xerial/util/FileResource.java"

Authors

leo

Value members

Concrete methods

def find(referenceClass: Class[_], resourceFileName: String): Option[URL]
def find(absoluteResourcePath: String): Option[URL]

Find a resource from the give absolute path

Find a resource from the give absolute path

def find(packageName: String, resourceFileName: String): Option[URL]

Finds the java.net.URL of the resource

Finds the java.net.URL of the resource

Value Params
packageName

the base package name to find the resource

resourceFileName

the resource file name relative to the package folder

Returns

the URL of the specified resource

def findClasses[A](packageName: String, toSearch: Class[A], classLoader: ClassLoader): Seq[Class[A]]
def findClasses[A](searchPath: Package, toSearch: Class[A], classLoader: ClassLoader): Seq[Class[A]]
def findResourceURLs(cl: ClassLoader, name: String): Seq[URL]

Find resource URLs that can be found from a given class loader and its ancestors

Find resource URLs that can be found from a given class loader and its ancestors

Value Params
cl

class loader

name

resource name

def listResources(packageName: String): Seq[VirtualFile]

Collect resources under the given package

Collect resources under the given package

def listResources(packageName: String, resourceFilter: String => Boolean, classLoader: ClassLoader): Seq[VirtualFile]

Collect resources under the given package

Collect resources under the given package

def open[U](referenceClass: Class[_], resourceFileName: String)(body: BufferedInputStream => U): U

Open a resource as a stream, then execute the code block using the stream

Open a resource as a stream, then execute the code block using the stream

Value Params
body

code block

referenceClass

context class to specify the package containing the resource file

resourceFileName

file name