multipart.downloaders
Class Downloader

java.lang.Object
  extended by multipart.downloaders.Downloader
All Implemented Interfaces:
IDownloader

public class Downloader
extends java.lang.Object
implements IDownloader

Implements the IDownloader interface using a URLConnection.


Constructor Summary
Downloader()
          Creates a new instance of Downloader
 
Method Summary
 void download(java.lang.String url, java.io.OutputStream dest)
          Downloads the file at url and outputs its contents to dest.
 java.lang.String downloadAsString(java.lang.String url)
          Returns the contents of url as a String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Downloader

public Downloader()
Creates a new instance of Downloader

Method Detail

download

public void download(java.lang.String url,
                     java.io.OutputStream dest)
              throws java.net.MalformedURLException,
                     java.io.IOException
Description copied from interface: IDownloader
Downloads the file at url and outputs its contents to dest.

Specified by:
download in interface IDownloader
Parameters:
url - A string specifying the URL of the remote file to download.
dest - The output destination for the downloaded data.
Throws:
java.net.MalformedURLException - If url is a malformed URL.
java.io.IOException - If the remote file cannot be downloaded.

downloadAsString

public java.lang.String downloadAsString(java.lang.String url)
                                  throws java.net.MalformedURLException,
                                         java.io.IOException
Description copied from interface: IDownloader
Returns the contents of url as a String.

Specified by:
downloadAsString in interface IDownloader
Parameters:
url - A string specifying the URL of the remote file to download.
Returns:
A string with the contents of the remote file.
Throws:
java.net.MalformedURLException - If url is a malformed URL.
java.io.IOException - If the remote file cannot be downloaded.