I don't agree with all that Keith wrote here -- buffering both input and output, then providing additional buffers and copying over and over again, but take a look at the code for copying from one file to another, from the Java Almanac::(I think you could do better by closing the streams in a finally block.) Given that url.openStream() returns an InputStream, all that needs to be added is q.e.d.
Originally posted by Joe Ess: If you already have an instance of BufferedImage, you can save it directly with the static write() method of javax.imageio.ImageIO
I think what the OP really wanted to do was copy from www.acme.com/coyote.gif to a local file xxx.gif. Converting the file back and forth to a BufferedImage is asking for trouble (apart from efficiency questions) -- what if you want to preserve the file's image format (woops, where's my gif writer?) and compression level, if any? Did you copy the file's metadata? Etc, etc...
There is no emoticon for what I am feeling!
Danger, 10,000 volts, very electic .... tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss