public class FileFetcher extends Object implements Fetcher
FileFetcher
fetches data from a given File
or path. The data is then passed in
to an instance of a FetcherStreamReader
.
This class takes care of opening and closing the file.
Constructor and Description |
---|
FileFetcher(File file)
Create a new instance of
FileFetcher , specifying the File to read from. |
FileFetcher(String filePath)
Create a new instance of
FileFetcher , specifying the path of the file. |
Modifier and Type | Method and Description |
---|---|
void |
executeFetcher(FetcherStreamReader reader)
Start this
Fetcher . |
File |
getFile()
Get the
File that this instance uses to read data from. |
public FileFetcher(String filePath)
FileFetcher
, specifying the path of the file.filePath
- The path to the file that is to be read from. Must not be null
or
empty.public void executeFetcher(FetcherStreamReader reader) throws IOException
Fetcher
Fetcher
. This will execute the fetcher and feed the stream of data in to
the supplied FetcherStreamReader
.executeFetcher
in interface Fetcher
reader
- Where the stream of data should be sent to.IOException
- When there was a problem during the fetching process. This may be
because, for example, of a network or a missing file.