Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tomcat how to keep temporary files?

I found out that when I call:

File.createTempFile();

in tomcat7 my temp file is created. BUT... it is deleted immediately after the Thread creating this file ends.

The default behavior of JVM should be to keep these files until it is shutdown. Apparently tomcat overwrites this behavior. Is there any switch to change this so that tomcat would keep the temp file?

like image 305
kosta5 Avatar asked Dec 10 '25 00:12

kosta5


1 Answers

File.createTempFile("filename","format");

will create a file with scope for that particular thread only.

May be manually calling like

File.deleteOnExit() 

might help.

like image 132
Naresh kumar Avatar answered Dec 12 '25 14:12

Naresh kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!