Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ImageIO.write buffered?

Should I write

BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(file));
ImageIO.write(im, "JPEG", os);

instead of

ImageIO.write(im, "JPEG", file);

I.e. are ImageIO file operations buffered by default or not?

Thanks!

like image 553
Andrey Minogin Avatar asked May 28 '26 03:05

Andrey Minogin


1 Answers

If you pass in a File, the underlying implementation will write directly to a RandomAccessFile (created in "rw" mode), so no buffering. Specifically, a FileImageOutputStream will be used as the ImageOutputStream.

like image 58
kschneid Avatar answered Jun 02 '26 06:06

kschneid