public final class Downloader extends Object
Constructor and Description |
---|
Downloader(Settings settings)
Constructs a new downloader object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkForCommonExceptionTypes(IOException ex)
Analyzes the IOException, logs the appropriate information for debugging
purposes, and then throws a DownloadFailedException that wraps the IO
Exception for common IO Exceptions.
|
void |
fetchFile(URL url,
File outputPath)
Retrieves a file from a given URL and saves it to the outputPath.
|
void |
fetchFile(URL url,
File outputPath,
boolean useProxy)
Retrieves a file from a given URL and saves it to the outputPath.
|
long |
getLastModified(URL url)
Makes an HTTP Head request to retrieve the last modified date of the
given URL.
|
public Downloader(Settings settings)
settings
- the configured settingspublic void fetchFile(URL url, File outputPath) throws DownloadFailedException
url
- the URL of the file to downloadoutputPath
- the path to the save the file toDownloadFailedException
- is thrown if there is an error
downloading the filepublic void fetchFile(URL url, File outputPath, boolean useProxy) throws DownloadFailedException
url
- the URL of the file to downloadoutputPath
- the path to the save the file touseProxy
- whether to use the configured proxy when downloading
filesDownloadFailedException
- is thrown if there is an error
downloading the filepublic long getLastModified(URL url) throws DownloadFailedException
url
- the URL to retrieve the timestamp fromDownloadFailedException
- is thrown if an exception occurs making
the HTTP requestprotected void checkForCommonExceptionTypes(IOException ex) throws DownloadFailedException
ex
- the original exceptionDownloadFailedException
- a wrapper exception that contains the
original exception as the causeCopyright © 2012–2019 OWASP. All rights reserved.