Greetings. I already managed to acquire an image by using the BufferedImage class - and with some fiddling I found out how I can save it to a file, BUT...
...the thing is, I'd like the image to be saved without being recompressed so that the resulting image file is a 1:1 copy of what I started with.
If someone says "why not just copy it then" - I'm retrieving the image from the web, so I can't just copy it. (erh... or can I?)
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...