deleteOnExit

The difference between the delete() method and deleteOnExit() method in Java.io.

delete () method Deletes a file directly when the delete () method is called, regardless of whether the file exists or not, and executes it as soon as it is called. deleteOnExit () method When the deleteOnExit () method is called, it is only equivalent to a declaration of deleteOnExit (), and the deleteOnExit () method is really called when the program is finished running and the JVM is terminated to achieve the delete operation.