public class ClasspathResourceFinderSimple extends Object implements ClasspathResourceFinder
Same as Class.getResourceAsStream(String)
except looks for resources with localized file names.
If the locale
is specified, then we look for resources whose name matches that locale.
For example, if looking for the resource
ClasspathResourceFinder.Null
Constructor and Description |
---|
ClasspathResourceFinderSimple() |
Modifier and Type | Method and Description |
---|---|
protected InputStream |
findClasspathResource(Class<?> baseClass,
String name,
Locale locale)
Workhorse method for retrieving a resource from the classpath.
|
InputStream |
findResource(Class<?> baseClass,
String name,
Locale locale)
Returns the contents of the resource with the specified name.
|
protected static Iterable<String> |
getCandidateFileNames(String fileName,
Locale l)
Returns the candidate file names for the specified file name in the specified locale.
|
public ClasspathResourceFinderSimple()
public InputStream findResource(Class<?> baseClass, String name, Locale locale) throws IOException
ClasspathResourceFinder
findResource
in interface ClasspathResourceFinder
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
protected InputStream findClasspathResource(Class<?> baseClass, String name, Locale locale) throws IOException
This method can be overridden by subclasses to provide customized handling of resource retrieval from the classpath.
baseClass
- The base class providing the classloader.name
- The resource name.locale
- The resource locale.
IOException
protected static Iterable<String> getCandidateFileNames(String fileName, Locale l)
For example, if looking for the
If the locale is
fileName
- The name of the file to get candidate file names on.l
- The locale.
Copyright © 2018 Apache. All rights reserved.