|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.anidb.http.AnimeTitlesDownloader
public class AnimeTitlesDownloader
A class for downloading the anime titles file.
You can use these anime titles for the seconds level cache. The xml data will be automatically downloaded and decompressed.
You should use the methods in the following order:
connect()
,
store(File)
, disconnect()
InputStream
:
connect()
, getInputStream()
, disconnect()
.disconnect()
until you have read all
the information you need from the InputStream
, because this call
will close the stream.store(File)
and/or getInputStream()
more than one time on a connected downloader. Before that you have to
disconnect and connect the downloader.
For further information look at Anime Titles.
Field Summary | |
---|---|
static java.lang.String |
ANIME_TITLES_ADDRESS
The default address for the file. |
static int |
TIMEOUT
The connection timeout. |
Constructor Summary | |
---|---|
AnimeTitlesDownloader()
Creates a downloader object. |
|
AnimeTitlesDownloader(java.lang.String address)
Creates a downloader object. |
|
AnimeTitlesDownloader(java.net.URL url)
Creates a downloader object. |
Method Summary | |
---|---|
void |
connect()
Connects the downloader to the server. |
void |
disconnect()
Disconnects the downloader from the server. |
java.io.InputStream |
getInputStream()
Returns an InputStream to the xml data. |
void |
store(java.io.File file)
Stores the xml data in a file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ANIME_TITLES_ADDRESS
public static final int TIMEOUT
Constructor Detail |
---|
public AnimeTitlesDownloader() throws java.net.MalformedURLException
java.net.MalformedURLException
- If the default address specifies an unknown
protocol.ANIME_TITLES_ADDRESS
public AnimeTitlesDownloader(java.net.URL url) throws HttpConnectionException
url
- The URL of the file.
java.lang.IllegalArgumentException
- If the URL is null
.
HttpConnectionException
- If the protocol of the URL isn't
http
or a new instance of the URL couldn't be created.public AnimeTitlesDownloader(java.lang.String address) throws java.net.MalformedURLException, HttpConnectionException
address
- The address of the file.
java.lang.IllegalArgumentException
- If the address is null
.
java.net.MalformedURLException
- If the address specifies an unknown
protocol.
HttpConnectionException
- If the protocol of the address isn't
http
.Method Detail |
---|
public void connect() throws java.io.IOException
java.lang.IllegalStateException
- If the downloader is already connected.
java.io.IOException
- If an error occured while opening the connection.public void disconnect()
java.lang.IllegalStateException
- If the downloader is already disconnected.public void store(java.io.File file) throws java.io.IOException
file
- The file.
java.lang.IllegalArgumentException
- If the file is null
.
java.lang.IllegalStateException
- If the downloader is already disconnected.
java.lang.IllegalStateException
- If the file has already been downloaded.
java.io.IOException
- If an I/O error occured while downloading the file
from the server or while writting it to the filesystem.public java.io.InputStream getInputStream() throws java.io.IOException
InputStream
to the xml data.
InputStream
.
java.lang.IllegalStateException
- If the downloader is already disconnected.
java.lang.IllegalStateException
- If the file has already been downloaded.
java.io.IOException
- If an I/O error occured while opening the stream to
the file on the server.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |