I've run into a bug that I only experience in Tomcat. If, within a servlet, I create a temporary
file using File.createTempFile(...), Tomcat puts the file in its "temp" directory, which is fine. However,
if I call deleteOnExit() on the file, the file doesn't get deleted when Tomcat is shut down. This happens
even when the temporary is never opened.


I am using Tomcat 5.5 on WindowsXP. Tomcat is installed as a "service", and I am stopped and restarting it using the "monitor" program. I also tried rebooting my machine (to make sure Java had exited) but the files were still there.

Has anyone else run into this?  Is there a workaround?

Thanks,
   --Paul Lynch

p.s.  Here's my test servlet's code:

// TempFileTest

import java.util.*;
import java.io.*;
import javax.servlet.http.*;

/**
* This class is a servlet used to test the problem with File.deleteOnExit()
*/
public class TempFileTest extends HttpServlet {
/**
* This method should be called automatically when the servlet is
* initialized.
*/
public void init() {
try {
File f = File.createTempFile("TEMP_FILE_TEST", null);
f.deleteOnExit();
}
catch (Exception e) {
System.out.println("TempFileTest could not create the temp file!");
e.printStackTrace();
}
} // init
} // TempFileTest



---------------------------------------------- Mailblocks - A Better Way to Do Email http://about.mailblocks.com/info


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to