Creating a Download
Manager in Java
ave you ever had an Internet download interrupted, putting you back at square
one? If you connect to the Internet with a dialup connection, it's very likely that
you've run into this all too common nuisance. Everything from call-waiting
disconnects to computer crashes can leave a download dead in its tracks. To say the
least, restarting a download from scratch over and over can be a very time-consuming
and frustrating experience.
A sometimes overlooked fact is that many interrupted downloads can be resumed.
This allows you to recommence downloading from the point at which a download terminates
instead of having to begin anew. In this chapter a tool called Download Manager is
developed that manages Internet downloads for you and makes simple work of resuming
interrupted downloads. It also lets you pause and then resume a download, and manage
multiple downloads, simultaneously.
At the core of the Download Manager 's usefulness is its ability to take advantage of
downloading only specific portions of a file. In a classic download scenario, a whole file
is downloaded from beginning to end. If the transmission of the file is interrupted for
any reason, the progress made toward completing the downloading of the file is lost. The
Download Manager, however, can pick up from where an interruption occurs and then
download only the file's remaining fragment. Not all downloads are created equal, though,
and there are some that simply cannot be restarted. Details on which files are and aren't
resumable are explained in the following section.
Not only is the Download Manager a useful utility, it is an excellent illustration of the
power and succinctness of Java's built-in APIs--especially as they apply to interfacing to
the Internet. Because the Internet was a driving force behind the creation of Java, it should
come as no surprise that Java's networking capabilities are unsurpassed. For example,
attempting to create the Download Manager in another language, such as C++, would
entail significantly more trouble and effort.
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks