12 Replies Latest reply: Jul 13, 2011 3:19 PM by jschellSomeoneStoleMyAlias RSS

    Status of BUG: File.deleteOnExit() does not work on open files (win32) ?

    875142
      I am a bit confused about the status of the below bug:

      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4171239
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6357433

      Is the fixed? I use jdk1.6.0_25 32bit on a windows 7 64 bit machine where I create a temp folder:
       
      
      
          File tempDir = File.createTempFile(name, "");
          if (!(tempDir.delete())) {
            throw new IOException("Could not delete temp file" + tempDir.getAbsolutePath());
          }
          if (!(tempDir.mkdir())) {
            throw new IOException("Could not create temp file" + tempDir.getAbsolutePath());
          }
          tempDir.deleteOnExit();
      It works fine if the folder is empty. But if I put a test.txt file in the folder created its not deleted on exit. Does deleteOnExit() only work on empty folders?