Re: Save gif file from the URL
- From: Thomas Fritsch <i.dont.like.spam@xxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 14:06:15 GMT
mark wrote:
I just want to save on disc a gif file taken from the internet (i.e.
save as logo.gif the image
http://www.google.com/intl/us_ALL/images/logo.gif ). Is it possible
without much effort (I have read about the extra & not free libraries
but I hope there is a simple way to do so (just read bytes and write
bytes - no modification).
In principle it is very easy:
URL url = new URL("http://www.google.com/intl/us_ALL/images/logo.gif");
InputStream input = url.openStream();
OutputStream output = new FileOutputStream("logo.gif");
for (int c = input.read(); c != -1; /**/)
output.write(c);
input.close();
output.close();
Try/catch for IOExceptions and performance-optimizing is left to the reader
as an exercise. ;-)
--
"Thomas:Fritsch$ops.de".replace(':', '.').replace('$', '@')
.
- Follow-Ups:
- Re: Save gif file from the URL
- From: Thomas Fritsch
- Re: Save gif file from the URL
- References:
- Save gif file from the URL
- From: mark
- Save gif file from the URL
- Prev by Date: Save gif file from the URL
- Next by Date: Re: understand the concept of interfaces
- Previous by thread: Save gif file from the URL
- Next by thread: Re: Save gif file from the URL
- Index(es):
Relevant Pages
|
|