Does Files.createTempDirectory
remove the directory after JVM exits normally? Or do I need to manually recursively remove the temporary directory content?
You can add apache commons io dependency to your project and then use FileUtils.deleteDirectory() to do something like:
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
FileUtils.deleteDirectory(tmp_dir_path.toFile());
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
For more information about apache commons check: https://commons.apache.org/proper/commons-io/