1
I need to convert a BufferedImage
for a File
. I tried it this way, but it didn’t work:
File file = null;
ImageIO.write(image, "jpg", file);
image
is the type BufferedImage
.
That was the mistake:
Exception in thread "AWT-Eventqueue-0" java.lang.Illegalargumentexception: output == null! at javax.imageio.Imageio.write(Unknown Source)*
Just to be clear: what you want is to save the image in a file.
File
is just a reference to the file, it contains no data, so it is not really possible convert data in aFile
, but create a reference to a file and then write the bytes or characters in the file.– utluiz