Package net.sf.basedb.util.bfs
Class DiskInputStreamLocator
- java.lang.Object
-
- net.sf.basedb.util.bfs.DiskInputStreamLocator
-
- All Implemented Interfaces:
InputStreamLocator
public class DiskInputStreamLocator extends Object implements InputStreamLocator
Input stream locator implementation that works with files on the local file system. The files must be located in the specified root directory. Subdirectories or parent paths are not supported.- Version:
- 2.15
- Author:
- Nicklas
- Last modified
- $Date: 2010-01-29 14:34:03 +0100 (fr, 29 jan 2010) $
-
-
Constructor Summary
Constructors Constructor Description DiskInputStreamLocator(File dir)
Create a new input stream locator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getInputStream(String filename)
Finds and opens an input stream to the file with the given filename.long
getSize(String filename)
Get the size in bytes of the given named resource.
-
-
-
Field Detail
-
dir
private final File dir
-
-
Constructor Detail
-
DiskInputStreamLocator
public DiskInputStreamLocator(File dir) throws IOException
Create a new input stream locator.- Parameters:
dir
- The directory in the local file system in which the files should be located- Throws:
NullPointerException
- If the dir parameter is nullFileNotFoundException
- If the given path is not an existing directoryIOException
-
-
Method Detail
-
getInputStream
public InputStream getInputStream(String filename) throws IOException
Finds and opens an input stream to the file with the given filename.- Specified by:
getInputStream
in interfaceInputStreamLocator
- Parameters:
filename
- The name (for example a file name) of the resource- Returns:
- An input stream
- Throws:
IOException
- If there is any problem with locating or opening the resource
-
getSize
public long getSize(String filename)
Description copied from interface:InputStreamLocator
Get the size in bytes of the given named resource.- Specified by:
getSize
in interfaceInputStreamLocator
- Parameters:
filename
- The name (for example a file name) of the resouce- Returns:
- The size in bytes, or -1 if not known
-
-