freixo
freixo

Reputation: 193

Is there a proper way to manage temporary files in Spring MVC context?

I mean I'm deleting them when I'm done but I want to cover all the possibilities and rule out the chance of leaving garbage behind. I read about File.createTempFile but it only deletes the temp file after the VM has been stopped...

Upvotes: 2

Views: 680

Answers (1)

Martin Frey
Martin Frey

Reputation: 10075

If you can specify the folder where your files are stored you can create a scheduled task that runs each hour and deletes the files older than one hour.

Take a look at the @Scheduled annotation.

Upvotes: 3

Related Questions