Package ca.corbett.extras.io
Class DownloadThread
java.lang.Object
ca.corbett.extras.io.DownloadThread
- All Implemented Interfaces:
Runnable
Manages a single download with progress notifications - you generally shouldn't need to interact
with this class directly; instances of this class are created and managed automatically
by the DownloadManager.
- Since:
- swing-extras 2.5
- Author:
- scorbo2 with help from claude.ai
-
Constructor Summary
ConstructorsConstructorDescriptionDownloadThread(HttpClient httpClient, URL url) Creates a DownloadThread for retrieving the contents of the given URL.DownloadThread(HttpClient httpClient, URL url, File targetDir) Creates a DownloadThread specifically for retrieving the contents of the given URL and saving it to the given target directory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDownloadListener(DownloadListener listener) booleanisKilled()Reports if the kill() method has been invoked on this thread.booleanReports if the download thread is actively downloading (or waiting on network).voidkill()Tells the thread to give up on the current download and terminate itself.voidremoveDownloadListener(DownloadListener listener) voidrun()
-
Constructor Details
-
DownloadThread
Creates a DownloadThread for retrieving the contents of the given URL. The resulting file will be saved in the system temp dir and provided via callback. -
DownloadThread
Creates a DownloadThread specifically for retrieving the contents of the given URL and saving it to the given target directory. The file name is preserved from whatever is at the end of the given URL. If targetDir is null, the system temp dir is used.
-
-
Method Details
-
addDownloadListener
-
removeDownloadListener
-
isRunning
public boolean isRunning()Reports if the download thread is actively downloading (or waiting on network). -
isKilled
public boolean isKilled()Reports if the kill() method has been invoked on this thread. -
kill
public void kill()Tells the thread to give up on the current download and terminate itself. The download will be treated as a failure. Does nothing if the thread had already completed before this method was invoked, or if the thread had not yet been started before this method was invoked. -
run
public void run()
-