935090232@qq.com
2021-07-09 3cd342a343fd67a32415b832abe1a39bab9e627d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.File;
import java.io.IOException;
 
/**
 * 文件对比复制
 * @author JIANGYOUYAO
 * @date 2021/6/7 0007
 */
public class findC {
 
 
    static  String targetFilePath="C:/";
    static  Long _1mb=1024L*1024L;
 
    public static void main(String[] args) throws IOException {
 
 
        File sourceFile=new File(targetFilePath);
        traverseFolder(sourceFile);
 
 
    }
 
 
    public static  void traverseFolder(File file) throws IOException {
 
        if (file.exists()) {
            File[] files = file.listFiles();
            if (null == files || files.length == 0) {
                return;
            } else {
                for (File file2 : files) {
                    if (file2.isDirectory()) {
 
                        traverseFolder(file2);
                    } else {
                        if(file2.length()>_1mb*100){
                            System.out.println( file2.length()/_1mb+"MB"+"\t"+file2.getAbsolutePath());
                        }
                    }
                }
            }
        } else {
            System.out.println("文件不存在!");
        }
    }
 
 
 
}