com.blogspot.applications4android.comicreader.core
Class Downloader

java.lang.Object
  extended by com.blogspot.applications4android.comicreader.core.Downloader

public class Downloader
extends java.lang.Object

Class containing utility functions for downloading the URI's


Method Summary
static java.lang.String decodeHtml(java.lang.String in)
          Replaces all sort of ''' kind of occurences in HTML strings with their corresponding ASCII chars.
static void dnldImage(java.lang.String file, java.net.URI uri)
          Helper function to download the image from the given uri into a local file
static java.lang.String downloadToString(java.net.URI uri)
          Helper function to download a URI from the given url and save it to a string.
static java.io.BufferedReader openConnection(java.net.URI uri)
          Open a http connection with the given url
static java.io.BufferedInputStream openConnectionStream(java.net.URI uri)
          Open a http connection with the given url
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

downloadToString

public static java.lang.String downloadToString(java.net.URI uri)
                                         throws ClientProtocolException,
                                                java.net.URISyntaxException,
                                                java.io.IOException
Helper function to download a URI from the given url and save it to a string. Uses URLConnection in order to set up a connection with the server and download the URI requested.

Parameters:
uri - The url of interest.
Returns:
the contents of the url in a string
Throws:
java.io.IOException
java.net.URISyntaxException
ClientProtocolException

openConnection

public static java.io.BufferedReader openConnection(java.net.URI uri)
                                             throws java.net.URISyntaxException,
                                                    ClientProtocolException,
                                                    java.io.IOException
Open a http connection with the given url

Parameters:
uri - desired url
Returns:
buffered reader for this url connection
Throws:
java.net.URISyntaxException
java.io.IOException
ClientProtocolException

openConnectionStream

public static java.io.BufferedInputStream openConnectionStream(java.net.URI uri)
                                                        throws java.net.URISyntaxException,
                                                               ClientProtocolException,
                                                               java.io.IOException
Open a http connection with the given url

Parameters:
uri - desired url
Returns:
buffered reader stream for this url connection
Throws:
java.net.URISyntaxException
java.io.IOException
ClientProtocolException

dnldImage

public static void dnldImage(java.lang.String file,
                             java.net.URI uri)
                      throws ComicSDCardFull,
                             ClientProtocolException,
                             java.net.URISyntaxException,
                             java.io.IOException
Helper function to download the image from the given uri into a local file

Parameters:
file - local file to store the image
uri - url from which to download the image
Throws:
ComicSDCardFull
ClientProtocolException
java.net.URISyntaxException
java.io.IOException

decodeHtml

public static java.lang.String decodeHtml(java.lang.String in)
Replaces all sort of ''' kind of occurences in HTML strings with their corresponding ASCII chars.

Parameters:
in - the input HTML string
Returns:
the ASCII-converted string