dcb
2025-06-18 4c4d0f591f94428ed7e5d2f4ae5df5c5087d8c26
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
package com.se.nsl.utils;
 
import java.io.File;
import java.util.ArrayList;
import java.util.List;
 
/**
 *
 */
public class FileUtil {
    public static String getShpPath(String dirPath) {
        File root = new File(dirPath);
        List<String> filePath=new ArrayList<>();
        traverse(root,filePath);
        for (String path:filePath
             ) {
            if (path.endsWith(".shp")){
                return path;
            }
        }
        return null;
    }
 
    public static void traverse(File dir,List<String> filePath) {
        File[] files = dir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    traverse(file, filePath);
                } else {
                    filePath.add(file.getAbsolutePath());
                }
            }
        }
    }
 
}