I have to fetch an image from the given URL and resize it before displaying the same on the html page.
I am able to do this using java.awt.image.BufferedImage and javax.imageio.ImageIO APIs. But I need to do the same without using java.awt. I tried the following code but it's not working. The output file doesn't contain the image.
And what is the purpose of writing to a ByteArrayOutputStream and then copying from that to a FileOutputStream? Why not just write directly to the FileOutputStream? (With the corrected code as per Carey Brown's comment, of course.)