public class DownloadFileTask extends PleaseWaitRunnable
| Modifier and Type | Class and Description |
|---|---|
private static class |
DownloadFileTask.DownloadException |
| Modifier and Type | Field and Description |
|---|---|
private String |
address |
private boolean |
canceled |
private HttpClient |
downloadConnection |
private File |
file |
private boolean |
mkdir |
private boolean |
unpack |
progressMonitor| Constructor and Description |
|---|
DownloadFileTask(Component parent,
String address,
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(File file,
String dir)
Recursive unzipping function
TODO: May be placed somewhere else - Tools.Utils?
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, runprivate final boolean mkdir
private final boolean unpack
private boolean canceled
private HttpClient downloadConnection
public DownloadFileTask(Component parent, String address, 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 otherwiseIllegalArgumentException - 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 SAXException, IOException
PleaseWaitRunnablerealRun in class PleaseWaitRunnableSAXException - if a SAX error occursIOException - if an I/O error occurspublic boolean isCanceled()
true if the task was canceled by the user, false otherwisepublic static void unzipFileRecursively(File file, String dir) throws IOException
file - zip filedir - output directoryIOException - if any I/O error occurs