public class DownloadFileTask extends PleaseWaitRunnable
| Modifier and Type | Class and Description |
|---|---|
private static class |
DownloadFileTask.DownloadException |
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
address |
private boolean |
canceled |
private java.net.HttpURLConnection |
downloadConnection |
private java.io.File |
file |
private boolean |
mkdir |
private boolean |
unpack |
progressMonitor| Constructor and Description |
|---|
DownloadFileTask(java.awt.Component parent,
java.lang.String address,
java.io.File file,
boolean mkdir,
boolean unpack)
Creates the download task
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancel()
User pressed cancel button.
|
private void |
closeConnectionIfNeeded() |
void |
download()
Performs download.
|
protected void |
finish()
Finish up the data work.
|
boolean |
isCanceled()
Replies true if the task was canceled by the user
|
protected void |
realRun()
Called in the worker thread to do the actual work.
|
static void |
unzipFileRecursively(java.io.File file,
java.lang.String dir)
Recursive unzipping function
TODO: May be placed somewhere else - Tools.Utils?
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, runprivate final java.lang.String address
private final java.io.File file
private final boolean mkdir
private final boolean unpack
private boolean canceled
private java.net.HttpURLConnection downloadConnection
public DownloadFileTask(java.awt.Component parent, java.lang.String address, java.io.File file, boolean mkdir, boolean unpack)
parent - the parent component relative to which the PleaseWaitDialog is displayedaddress - the URL to downloadfile - The destination filemkdir - true if the destination directory must be created, false otherwiseunpack - true if zip archives must be unpacked recursively, false otherwisejava.lang.IllegalArgumentException - if parent is nullprivate void closeConnectionIfNeeded()
protected void cancel()
PleaseWaitRunnablecancel in class PleaseWaitRunnableprotected void finish()
PleaseWaitRunnablefinish in class PleaseWaitRunnablepublic void download() throws DownloadFileTask.DownloadException
DownloadFileTask.DownloadException - if the URL is invalid or if any I/O error occurs.protected void realRun() throws org.xml.sax.SAXException, java.io.IOException
PleaseWaitRunnablerealRun in class PleaseWaitRunnableorg.xml.sax.SAXExceptionjava.io.IOExceptionpublic boolean isCanceled()
true if the task was canceled by the user, false otherwisepublic static void unzipFileRecursively(java.io.File file, java.lang.String dir) throws java.io.IOException
file - dir - java.io.IOException