A Web application runs on tomcat server, creates a temp files and deletes it once its usage over, but some error scenarios temp files are not being deleted. which are stacked up and never deleted. Used deleteOnExit() seems not working, after tomcat server shutdown also these temp files still exisitng in system.
The error of the files not deleted looks like some process still holds lock on that, so planning to write a thread/scheduler class which queue all these error temp files and re-tries until these are deleted sucessfully from system..
ShutdownHook is similar to my thought but the only drawback i am seeing is it only runs on shutdown, is their any best practices available to this problem. Any suggestions.