code: private static void deleteDirectoryOnExit(File directory) throws IOException {
      if (!directory.exists()) {
        return;
      }
  
      directory.deleteOnExit();
      if (!isSymlink(directory)) {
        cleanDirectoryOnExit(directory);
      }
    }
docs: Schedules a directory recursively for deletion on JVM exit.
  
  @param directory  directory to delete, must not be <code>null</code>
  @throws NullPointerException if the directory is <code>null</code>
  @throws IOException in case deletion is unsuccessful