Re: Save gif file from the URL
- From: Thomas Fritsch <i.dont.like.spam@xxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 14:36:54 GMT
Thomas Fritsch schrieb:
mark wrote:Sorry for the bug. I meant:
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; /**/)
for (int c = input.read(); c != -1; c = input.read())
output.write(c);
input.close();
output.close();
Try/catch for IOExceptions and performance-optimizing is left to the reader
as an exercise. ;-)
--
Thomas
.
- References:
- Save gif file from the URL
- From: mark
- Re: Save gif file from the URL
- From: Thomas Fritsch
- Save gif file from the URL
- Prev by Date: Re: understand the concept of interfaces
- Next by Date: Trouble with ArrayList
- Previous by thread: Re: Save gif file from the URL
- Next by thread: Trouble with ArrayList
- Index(es):