Link to home
Start Free TrialLog in
Avatar of SaadDani
SaadDaniFlag for Israel

asked on

delete files older than a date

In java I want to delete all the files in a directory with an extension "*.xxx" an older then 5 days.
How can I do this?
Avatar of Mick Barry
Mick Barry
Flag of Australia image

use the following

http://www.objects.com.au/java/qa/600134565.html

and add a check for each files date
Avatar of SaadDani

ASKER

this I already know to do, but how I delete aonly those file with a specified extension and older then 5 days?
ASKER CERTIFIED SOLUTION
Avatar of sciuriware
sciuriware

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sciuriware
sciuriware

if (f.lastModified < then && name.substring(name.length() - 3).equals("xxx"))

better:

if (f.lastModified < then && name.substring(name.length() - 4).equals(".xxx"))

;JOOP!