I am using Apache PDFBox to convert PDF to TIF file.
The scenario is to generate TIF file to a specific path, then another application will read this TIF file and move to another directory.
But it will generate TIF file with 0-kb at times and fail to open this TIF file, and does not have any abnormal message in application log.
Here is the code snippet:
We can see implementation details in ImageIOUtil.writeImage
We can see it will create a File instance at first, then write image to TIF file.
As it create a File instance, this file will be created. It another application had read this file, then this file may be locked and failed to write.
Therefore, we should create TIF file to a temporary directory first, then move the finished TIF file to the destination.