Holger's
Java API

com.antelmann.net
Class JDownloader

java.lang.Object
  extended by java.lang.Thread
      extended by com.antelmann.net.JDownloader
All Implemented Interfaces:
Runnable

public class JDownloader
extends Thread

Downloads a URL or URLCache object into a file in a thread using a ProgressMonitorInputStream, so that the user can abort if desired

Author:
Holger Antelmann
See Also:
Downloader, JWebBrowser, ProgressMonitorInputStream

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JDownloader(Component parent, URLCache uc, File file)
           
JDownloader(Component parent, URL url, File file)
           
 
Method Summary
static URL createFtpUrl(String host, String remoteDir, String name, String user, String password)
           
 int getContentLength()
          returns the content length of the URL once download started; returns -2 if the thread hasn't been started, yet, or -1 if the length is unknown.
 IOException getException()
          if an IOException occurred during download, it can be later accessed through this method.
 File getFile()
           
 int getReadSoFar()
          returns the bytes that have been read by the thread; returns -3 if the thread hasn't been started, yet
 boolean getShowEndDialog()
          returns true if the end-dialog is shown after download (true by default)
 URL getURL()
           
 void run()
          downloads the URL to the file and starts the ProgressMonitor
 void setBasicAuthorization(String user, char[] password)
           
 void setBasicAuthorization(String user, String password)
           
 void setShowEndDialog(boolean on)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JDownloader

public JDownloader(Component parent,
                   URL url,
                   File file)

JDownloader

public JDownloader(Component parent,
                   URLCache uc,
                   File file)
Method Detail

setBasicAuthorization

public void setBasicAuthorization(String user,
                                  String password)

setBasicAuthorization

public void setBasicAuthorization(String user,
                                  char[] password)

getShowEndDialog

public boolean getShowEndDialog()
returns true if the end-dialog is shown after download (true by default)


setShowEndDialog

public void setShowEndDialog(boolean on)

getReadSoFar

public int getReadSoFar()
returns the bytes that have been read by the thread; returns -3 if the thread hasn't been started, yet


getURL

public URL getURL()

getFile

public File getFile()

getContentLength

public int getContentLength()
returns the content length of the URL once download started; returns -2 if the thread hasn't been started, yet, or -1 if the length is unknown.


getException

public IOException getException()
if an IOException occurred during download, it can be later accessed through this method.


run

public void run()
downloads the URL to the file and starts the ProgressMonitor

Specified by:
run in interface Runnable
Overrides:
run in class Thread

createFtpUrl

public static URL createFtpUrl(String host,
                               String remoteDir,
                               String name,
                               String user,
                               String password)
                        throws MalformedURLException
Throws:
MalformedURLException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads