Does `javax.imageio.ImageIO` require file locking?

My app is saving images into a folder. Simultaneously another piece of software watches over this folder and prints pasted images.

Problem I've encountered is that printing app can send on printer half rendered image or doesn't react to saved images at all.

I'm using javax.imageio.ImageIO.write(RenderedImage im, String formatName, File output) to save BufferedImage into png format.

If locking required please provide a code example with explicit locks. If not explain why.

I've tested on Windows, JRE 1.8

-------------Problems Reply------------

Basically, you should write the image to a temporary file and then rename it to the final file name. this way the file is completely written before the other app becomes aware of it.

You probably want to implement some kind of locking mechanism that files are only read when they are completely written, or not at all.

Category:java Views:5 Time:2018-03-12

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.468 (s). 11 q(s)