Package libcore.io

Class DeleteOnExit

  • All Implemented Interfaces:
    Runnable

    public class DeleteOnExit
    extends Thread
    Implements the actual DeleteOnExit mechanism. Is registered as a shutdown hook in the Runtime, once it is actually being used.
    • Method Detail

      • getInstance

        public static DeleteOnExit getInstance()
        Returns our singleton instance, creating it if necessary.
      • addFile

        public void addFile​(String filename)
        Schedules a file for deletion.
        Parameters:
        filename - The file to delete.
      • run

        public void run()
        Does the actual work. Note we (a) first sort the files lexicographically and then (b) delete them in reverse order. This is to make sure files get deleted before their parent directories.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
        See Also:
        Thread.start()