java 删除所有早于N天的文件(递归选项,它遍历子文件夹)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public static void recursiveDeleteFilesOlderThanNDays( int days, String dirPath) throws IOException { long cutOff = System.currentTimeMillis() - (days * 24 * 60 * 60 * 1000 ); Files.list(Paths.get(dirPath)) .forEach(path -> { if (Files.isDirectory(path)) { try { recursiveDeleteFilesOlderThanNDays(days, path.toString()); } catch (IOException e) { // log here and move on } } else { try { if (Files.getLastModifiedTime(path).to(TimeUnit.MILLISECONDS) < cutOff) { Files.delete(path); } } catch (IOException ex) { // log here and move on } } }); } |
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 分享4款.NET开源、免费、实用的商城系统
· 解决跨域问题的这6种方案,真香!
· 5. Nginx 负载均衡配置案例(附有详细截图说明++)
· Windows 提权-UAC 绕过
2019-12-04 MySQL的统计总数count(*)与count(id)或count(字段)的之间的各自效率性能对比