We have upgraded iText version from 5.0 to 5.5.9 in few of our applications. After that we are facing issues in File.renameTo calls. Its returning false.
If we replace back the previous version of iText, it is working fine.
Once iText merges the pdf's, those pdf's are not getting moved to different folder.
If you are running your code on Windows, the file may not have been closed properly, and you rely on the garbage collector to do it.
So you may try to run the same program on Linux to check this hypothesis.
This can be a regression in iText or your code was broken even with the previous version of iText, but with the difference of implementation, the garbage collector did its job before you called File.renameTo
.
As told on the comments of your post, the single line File.renameTo(sourceFilePath, targetFilePath)
is not enough to understand your issue. We need the context to understand the problem.
As a reminder the Java doc says :
Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.
Note that the Files class defines the move method to move or rename a file in a platform independent manner.