public class JavaDownloadAction extends AbstractDownloadAction
DownloadAction which uses
java's builtin HttpURLConnection.
Created by covers1624 on 16/12/21.
DownloadAction.Destdest, downloadListener, FORMAT_ASCTIME, FORMAT_RFC1036, FORMAT_RFC1123, headers, onlyIfModified, PATTERNS, quiet, upToDate, url, useETag, userAgent| Constructor and Description |
|---|
JavaDownloadAction() |
| Modifier and Type | Method and Description |
|---|---|
JavaDownloadAction |
addRequestHeader(java.lang.String key,
java.lang.String value)
Adds an arbitrary Http header to the action.
|
void |
execute()
Execute the download action.
|
JavaDownloadAction |
setDest(DownloadAction.Dest dest)
Set the Destination to download content to.
|
JavaDownloadAction |
setDest(java.io.File file)
Set the
File to download content to. |
JavaDownloadAction |
setDest(java.io.OutputStream os)
Set the
OutputStream to download content to. |
JavaDownloadAction |
setDest(java.nio.file.Path path)
Set the
Path to download content to. |
JavaDownloadAction |
setDest(java.io.StringWriter sw)
Set the
StringWriter to download content to. |
JavaDownloadAction |
setDownloadListener(DownloadListener downloadListener)
Set the
DownloadListener to use. |
JavaDownloadAction |
setOnlyIfModified(boolean onlyIfModified)
If this Download action should use
If-Modified-Since
HTTP request header. |
JavaDownloadAction |
setQuiet(boolean quiet)
If this download action should not log things.
|
JavaDownloadAction |
setUrl(java.lang.String url)
Set the URL to download from.
|
JavaDownloadAction |
setUseETag(boolean useETag)
If this download action should use
If-None-Match
HTTP request header. |
JavaDownloadAction |
setUserAgent(java.lang.String userAgent)
Sets the
User-Agent HTTP request header. |
calcUpToDate, expectNotModified, getDest, getDownloadListener, getOnlyIfModified, getQuiet, getUrl, getUseETag, getUserAgent, isUpToDate, parseDate, validateCodepublic void execute()
throws java.io.IOException
DownloadActionjava.io.IOException - If an IO error occurs whilst downloading.HttpResponseException - If the response code was not expected.public JavaDownloadAction setUrl(java.lang.String url)
DownloadActionsetUrl in interface DownloadActionsetUrl in class AbstractDownloadActionurl - The URL.public JavaDownloadAction setDest(DownloadAction.Dest dest)
DownloadActionsetDest in interface DownloadActionsetDest in class AbstractDownloadActiondest - The Destination.public JavaDownloadAction setDest(java.io.StringWriter sw)
DownloadActionStringWriter to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionsw - The StringWriter.public JavaDownloadAction setDest(java.io.OutputStream os)
DownloadActionOutputStream to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionos - The OutputStream.public JavaDownloadAction setDest(java.io.File file)
DownloadActionFile to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionfile - The file.public JavaDownloadAction setDest(java.nio.file.Path path)
DownloadActionPath to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionpath - The path.public JavaDownloadAction setOnlyIfModified(boolean onlyIfModified)
DownloadActionIf-Modified-Since
HTTP request header.setOnlyIfModified in interface DownloadActionsetOnlyIfModified in class AbstractDownloadActiononlyIfModified - If If-Modified-Since should be used.public JavaDownloadAction setUseETag(boolean useETag)
DownloadActionIf-None-Match
HTTP request header.setUseETag in interface DownloadActionsetUseETag in class AbstractDownloadActionuseETag - If If-None-Match should be used.public JavaDownloadAction setQuiet(boolean quiet)
DownloadActionsetQuiet in interface DownloadActionsetQuiet in class AbstractDownloadActionquiet - If the download action should be quiet.public JavaDownloadAction setUserAgent(java.lang.String userAgent)
DownloadActionUser-Agent HTTP request header.setUserAgent in interface DownloadActionsetUserAgent in class AbstractDownloadActionuserAgent - The User-Agent request header.public JavaDownloadAction addRequestHeader(java.lang.String key, java.lang.String value)
DownloadActionaddRequestHeader in interface DownloadActionaddRequestHeader in class AbstractDownloadActionkey - The key.value - The value.public JavaDownloadAction setDownloadListener(DownloadListener downloadListener)
DownloadActionDownloadListener to use.setDownloadListener in interface DownloadActionsetDownloadListener in class AbstractDownloadActiondownloadListener - The DownloadListener.