public class ClassPathResourceLocator extends Object implements ResourceLocator
ResourceLocator
for the class path.Constructor and Description |
---|
ClassPathResourceLocator(String classPathPrefix,
ClassLoader classLoader,
String... defaultDirectoryFileNames)
Initiate.
|
Modifier and Type | Method and Description |
---|---|
URL |
getResource(String resourcePath)
Obtains the
URL for the resource. |
InputStream |
getResourceAsStream(String resourcePath)
Obtains the
InputStream to the contents of the resource. |
Set<String> |
getResourceChildren(String resourcePath)
Obtains the direct children for the resource.
|
public ClassPathResourceLocator(String classPathPrefix, ClassLoader classLoader, String... defaultDirectoryFileNames)
classPathPrefix
- Class path prefix.classLoader
- ClassLoader
to use to locate resources.defaultDirectoryFileNames
- Names of the default files within a directory.public Set<String> getResourceChildren(String resourcePath)
ResourceLocator
getResourceChildren
in interface ResourceLocator
resourcePath
- Path to the resource.public URL getResource(String resourcePath) throws MalformedURLException
ResourceLocator
URL
for the resource.getResource
in interface ResourceLocator
resourcePath
- Path to the resource.URL
to the resource or null
if no resource
at path.MalformedURLException
- If resource path is malformed.public InputStream getResourceAsStream(String resourcePath)
ResourceLocator
InputStream
to the contents of the resource.getResourceAsStream
in interface ResourceLocator
resourcePath
- Path to the resource.InputStream
to the contents of the resource or
null
if no resource at path.Copyright © 2005–2016. All rights reserved.