org.jscience.net
Class JDownloader

java.lang.Object
  extended by java.lang.Thread
      extended by org.jscience.net.JDownloader
All Implemented Interfaces:
java.lang.Runnable

public class JDownloader
extends java.lang.Thread

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

See Also:
Downloader, JWebBrowser, ProgressMonitorInputStream

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JDownloader(java.awt.Component parent, URLCache uc, java.io.File file)
          Creates a new JDownloader object.
JDownloader(java.awt.Component parent, java.net.URL url, java.io.File file)
          Creates a new JDownloader object.
 
Method Summary
 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.
 java.io.IOException getException()
          if an IOException occurred during download, it can be later accessed through this method.
 java.io.File getFile()
          DOCUMENT ME!
 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)
 java.net.URL getURL()
          DOCUMENT ME!
 void run()
          downloads the URL to the file and starts the ProgressMonitor
 void setShowEndDialog(boolean on)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JDownloader

public JDownloader(java.awt.Component parent,
                   java.net.URL url,
                   java.io.File file)
Creates a new JDownloader object.

Parameters:
parent - DOCUMENT ME!
url - DOCUMENT ME!
file - DOCUMENT ME!

JDownloader

public JDownloader(java.awt.Component parent,
                   URLCache uc,
                   java.io.File file)
Creates a new JDownloader object.

Parameters:
parent - DOCUMENT ME!
uc - DOCUMENT ME!
file - DOCUMENT ME!
Method Detail

getShowEndDialog

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

Returns:
DOCUMENT ME!

setShowEndDialog

public void setShowEndDialog(boolean on)
DOCUMENT ME!

Parameters:
on - DOCUMENT ME!

getReadSoFar

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

Returns:
DOCUMENT ME!

getURL

public java.net.URL getURL()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getFile

public java.io.File getFile()
DOCUMENT ME!

Returns:
DOCUMENT ME!

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.

Returns:
DOCUMENT ME!

getException

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

Returns:
DOCUMENT ME!

run

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

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread