更新时间:2023-12-04 21:06:46
您可以使用 File.lastModified()
获取文件/目录的最后修改时间。
You can use File.lastModified()
to get the last modified time of a file/directory.
可以像这样使用:
long diff = new Date().getTime() - file.lastModified();
if (diff > x * 24 * 60 * 60 * 1000) {
file.delete();
}
删除早于 x $ c的文件$ c>(一个
int
)天。