检查文件日期,符合条件的文件复制到目标位置

网友投稿 464 2022-11-20

检查文件日期,符合条件的文件复制到目标位置

检查文件日期,符合条件的文件复制到目标位置

@RunWith(SpringRunner.class)@Slf4jpublic class CopyFile { @Test public void getNewFile() { String path = "E:\work\src"; String dstPath = "E:\work\dst"; String date = "2020-12-15"; List exclude = new ArrayList() {{ add(".svn"); add("logs"); }}; ls(path, date, exclude,path,dstPath); } private void ls(String path, String date, List exclude,String rootSrc,String rootDst) { Date afterDate = DateUtil.parse(date); File[] ls = FileUtil.ls(path); for (File f : ls) { if ( afterDate.before(DateUtil.date(f.lastModified())) && f.isFile()) { String dstPath = StrUtil.replace(f.getPath(), rootSrc, rootDst); FileUtil.copy(f.getPath(),dstPath,true);// log.info("{},{},{}", f, DateUtil.date(f.lastModified()),dstPath); } if (f.isDirectory() && exclude.stream().filter(s -> f.getName().equals(s)).count() == 0) { ls(f.getPath(), date, exclude,rootSrc,rootDst); } } }}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:wpf中的datagrid绑定类集合与datatable
下一篇:antd select 设置默认选中
相关文章

 发表评论

暂时没有评论,来抢沙发吧~