Delete files older than x days
You can use File.lastModified() to get the last modified time of a file/directory. Can be used like this: long diff = new Date().getTime() – file.lastModified(); if (diff > x * 24 * 60 * 60 * 1000) { file.delete(); } Which deletes files older than x (an int) days.