Delete temp file during finally vs delete output file during catch
- by Russell
This is in Java 6.
I've seen more than once that people create temp files, do something, then rename it to the output file. Everything is wrapped in a try-finally block, where the temp file is deleted in finally in case something goes wrong in between.
try {
//do something with tempFile
//do something with tempFile
//do something with…