Package org.onehippo.repository.util
Class FileContentResourceLoader
- java.lang.Object
-
- org.onehippo.repository.util.FileContentResourceLoader
-
- All Implemented Interfaces:
ContentResourceLoader
public class FileContentResourceLoader extends Object implements ContentResourceLoader
ContentResourceLoader
implementation for loading resources from a directory.
-
-
Constructor Summary
Constructors Constructor Description FileContentResourceLoader(File baseDir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URL
getResource(String path)
Returns a URL in file URL scheme.InputStream
getResourceAsStream(String path)
Returns the resource located at the named path as anInputStream
object.
-
-
-
Constructor Detail
-
FileContentResourceLoader
public FileContentResourceLoader(File baseDir)
-
-
Method Detail
-
getResource
public URL getResource(String path) throws MalformedURLException
Returns a URL in file URL scheme.- Specified by:
getResource
in interfaceContentResourceLoader
- Parameters:
path
- aString
specifying the path to the resource- Returns:
- the resource located at the named path,
or
null
if there is no resource at that path - Throws:
MalformedURLException
- if the pathname is not given in the correct form- See Also:
- http://en.wikipedia.org/wiki/URI_scheme
-
getResourceAsStream
public InputStream getResourceAsStream(String path) throws IOException
Description copied from interface:ContentResourceLoader
Returns the resource located at the named path as anInputStream
object.The path must be specified according to the rules given in
getResource
. This method returnsnull
if no resource exists at the specified path.- Specified by:
getResourceAsStream
in interfaceContentResourceLoader
- Parameters:
path
- aString
specifying the path to the resource- Returns:
- the
InputStream
returned to the caller, ornull
if no resource exists at the specified path - Throws:
IOException
-
-