code: public static void forceDeleteOnExit(File file) throws IOException {
      if (file.isDirectory()) {
        deleteDirectoryOnExit(file);
      } else {
        file.deleteOnExit();
      }
    }
docs: Schedules a file to be deleted when JVM exits.
  If file is directory delete it and all sub-directories.
  
  @param file  file or directory to delete, must not be <code>null</code>
  @throws NullPointerException if the file is <code>null</code>
  @throws IOException in case deletion is unsuccessful