Runtime.addShutdownHook(), because it seems not to be called sometimes
on Windows, or at least seems not to be allowed to run to conclusion.
Renaming the files, and then deleting them. Fails on the renaming.
I really don’t like the idea of leaving last session’s temp files to be
cleaned up by the next session—we should have VASSAL check for old temp
files to remove on startup, but I don’t want that to be the usual way
that temp files are removed.
Is it possible to spawn another process which will delete the temp files
after the main process has ended?
Runtime.getRuntime().exec("cmd /c del " + tmpFiles)
from a shutdown hook, where tmpFiles is a space-separated list of temp
files to delete. Apparently the process spawned by exec runs after
the memory-mapped temp files have been unmapped, and so is able to remove