SafeResourceGetter

Provides safe and easy access to a resource. This will first try to get the resource from the class loader of the given class, and if that fails, it will try to get it from Class.getResourceAsStream and Class.getResource.

It also adds a slash to the path if it doesn't start with one.

Functions

Link copied to clipboard
fun getResource(clazz: Class<*>, path: String): URL?

Get resource as URL from the class loader of the given class, or from the class itself.

Link copied to clipboard

Get resource as stream from the class loader of the given class, or from the class itself.