I use the following code to create some temp files, and wrapped tem as inputsteam to send to client side.
I understand that the temp files can be deleted automatically b
It would be better if you can maintain a Set (Avoid Duplicates) for all files you create.
And iterate the file list and delete every file one by one.
public static final Set TMP_FILES = new HashSet<>();
And delete all by iterating.
public void deleteTempFiles() {
for(String myTempFile: TMP_FILES) {
try {
new File(myTempFile).delete();
} catch (Exception e) {
// Handle if needed.
}
}
}