public interface ResourceFinder
Essentially a wrapper around Class.getResourceAsStream(String)
, but with support for looking up resources
with localized names (e.g.
The following predefined implementations are provided:
SimpleResourceFinder
- Simple searching of classpath.
BasicResourceFinder
- Same as above, but looks in local JVM working directory if resource
can't be found on classpath.
RecursiveResourceFinder
- Same as above, except if the resource can't be found on the
classpath relative to the base class, recursively searches up the parent class hierarchy.
Modifier and Type | Interface and Description |
---|---|
static class |
ResourceFinder.Null
Represents "no" classpath resource finder.
|
Modifier and Type | Method and Description |
---|---|
InputStream |
findResource(Class<?> baseClass,
String name,
Locale locale)
Returns the contents of the resource with the specified name.
|
InputStream findResource(Class<?> baseClass, String name, Locale locale) throws IOException
baseClass
- The class to use to retrieve the resource.name
- The resource name.
See Class.getResource(String)
for format.locale
- The locale of the resource to retrieve.
IOException
- Thrown by underlying stream.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.