Class DownloadThread

java.lang.Object
ca.corbett.extras.io.DownloadThread
All Implemented Interfaces:
Runnable

public class DownloadThread extends Object implements 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 Details

    • DownloadThread

      public DownloadThread(HttpClient httpClient, URL url)
      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

      public 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. 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

      public void addDownloadListener(DownloadListener listener)
    • removeDownloadListener

      public void removeDownloadListener(DownloadListener listener)
    • 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()
      Specified by:
      run in interface Runnable