package com.sxd.createDao;

import java.io.File;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap; public class Test { private long a = 0;
Map<String, File> map = new HashMap<String, File>();
Map<String, String> repeatMap = new TreeMap<String ,String>();
@org.junit.Test
public void test() {
System.out.println(LocalDateTime.now());
//本机磁盘上所有文件
File [] files = File.listRoots();
for (File file : files) {
num(file);
}
// num(new File("D:/BaiduYunDownload")); //单个文件夹下 System.out.println("计算机文件总数:"+a);
System.out.println(LocalDateTime.now());
if(repeatMap.size() > 0){
repeatMap.forEach((k,v)->System.out.println("文件路径:"+k+" 文件名:"+v));
} } //计算文件夹下所有文件总数
public void num(File file){
if(file.isDirectory()){
File [] files = file.listFiles();
if(files != null){
for (File string : files) {
num(string);
}
}
}else{
a++;
if(map.containsKey(file.getName())){
File thisFile = map.get(file.getName());
if(file.getTotalSpace() == thisFile.getTotalSpace()){
repeatMap.put(file.getPath() , file.getName());
repeatMap.put(thisFile.getPath(),thisFile.getName());
}
}else{
map.put(file.getName(),file);
} }
}
}

最新文章

  1. JS高程5.引用类型(1)Object类型
  2. Apache服务器安装过程及问题的解决(for windows system32bit)
  3. 使用Auto Layout中的VFL(Visual format language)--代码实现自动布局【转】
  4. POJ 2689
  5. jQuery_效果(滑动)
  6. 海康、大华IpCamera RTSP地址和格式
  7. UVaLive 6855 Banks (水题,暴力)
  8. vim高亮显示
  9. Hackers’ Crackdown-----UVA11825-----DP+状态压缩
  10. js的内置对象
  11. EL表达式+JSTL
  12. How do I learn machine learning?
  13. tomcat的LifecycleException异常
  14. struts2中的namespace意义
  15. u-boot启动第二阶段以及界面命令分析
  16. Morton Code
  17. springboot项目,执行查询方法报错
  18. 与native交互时会出现的问题
  19. weakself的另一种写法
  20. Minimum Path Sum,最短路径问题,动态规划

热门文章

  1. bzoj 1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居——排序+贪心+set
  2. 【洛谷 UVA11417】 GCD(欧拉函数)
  3. bzoj 1002 找规律(基尔霍夫矩阵)
  4. Github上的几个C++开源项目
  5. XML解析代码
  6. 自建yum镜像
  7. python进程理论部分
  8. crontab执行脚本失败问题
  9. Selenium2+python自动化31-生成测试报告【转载】
  10. hdu 5176(并查集)