Why does not File.deleteOnExit work with directory?

java

Solution

The directory must be empty in order to delete it.

Problem

Am I using `deleteOnExit` in a wrong way? I create a directory and then run: `new File("my_dir_path").deleteOnExit();` But the directory is never removed after JVM terminates without error, despite that JDK doc says `Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.`

Original source