| Author |
Deleting old files in directory ?
|
Z Zia
Greenhorn
Joined: Oct 03, 2004
Posts: 24
|
|
Hello, I have some apps that process files and move them in a backup directory. I wish to delete old files from that directory and automate application; please suggest: 1. How can app delete files after a specific date. Example: I wish to delete all files that are more than 14 days old in a directory? 2. Please share code if somone has already develop this sort of component/ function. Regards,
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24041
|
|
|
Use java.io.File.listFiles() to get a list of the files in a directory, and then just use lastModified() to check the age of each file.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Z Zia, The info provided by Mr.Ernest is kinda enough to develop the application that fit your requirements... Could you try to code by yourself and learn things so that your programming skill will be improved? If you get stuck on something, you may ask questions here and we are here to help you...
|
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
|
 |
 |
|
|
subject: Deleting old files in directory ?
|
|
|