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());
|
}
|
}
|
}
|
}
|
|
}
|