To download directly from a URL:
- create a URL from the URL
string - create a URLConnection by sending openConnection to the URL
- on the connection, setUsesCaches to false, setDoInput to true, setDoOutput to false
- obtain the InputStream from the URLConnection
- copy the file using something like this:
(The IOUtil methods, part of a utility class here, simply ensure that the references aren't null before closing the streams.)
If you're looking to do this via
servlets, that's a different solution.
-Jeff L.-
[ January 19, 2004: Message edited by: Jeff Langr ]