PulpCore

pulpcore.net
Class Download

java.lang.Object
  extended by pulpcore.net.Download
All Implemented Interfaces:
Runnable

public class Download
extends Object
implements Runnable

Downloads a file into memory. Handles partial HTTP downloads if the first attempt downloads only a portion of the file.


Field Summary
static int CANCELED
           
static int DOWNLOADING
           
static int ERROR
           
static int IDLE
           
static int SUCCESS
           
 
Constructor Summary
Download(URL url)
           
 
Method Summary
 void cancel()
           
 int getBytesRead()
          Returns the number of bytes downloaded.
 byte[] getData()
           
 long getEstimatedTimeRemaining()
           
 Throwable getLastException()
           
 double getPercentDownloaded()
          Returns a values less than zero if the percent not known
 int getSize()
          Returns the size of the file currently downloading, or -1 if not known.
 int getState()
           
 void run()
           
 void start()
           
static Download startDownload(String file)
          Starts downloading a file from the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDLE

public static final int IDLE
See Also:
Constant Field Values

DOWNLOADING

public static final int DOWNLOADING
See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
See Also:
Constant Field Values

CANCELED

public static final int CANCELED
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values
Constructor Detail

Download

public Download(URL url)
Method Detail

startDownload

public static Download startDownload(String file)
Starts downloading a file from the server. Returns immediatly.

Returns:
a Download object, or null if the path is invalid.

start

public void start()

cancel

public void cancel()

getSize

public int getSize()
Returns the size of the file currently downloading, or -1 if not known.


getBytesRead

public int getBytesRead()
Returns the number of bytes downloaded.


getPercentDownloaded

public double getPercentDownloaded()
Returns a values less than zero if the percent not known


getLastException

public Throwable getLastException()

getData

public byte[] getData()

getState

public int getState()

getEstimatedTimeRemaining

public long getEstimatedTimeRemaining()

run

public void run()
Specified by:
run in interface Runnable

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.