/**
* 获取路径下的所有文件/文件夹
* @param directoryPath 需要遍历的文件夹路径
* @return
*/
public static List<String> getAllFile(String directoryPath) {
LinkedList list = new LinkedList();
if(directoryPath==null){
return list;
}
File baseFiles = new File(directoryPath);
if (baseFiles==null||baseFiles.isFile() || !baseFiles.exists()) {
return list;
}
File[] files = baseFiles.listFiles();
if (files==null) {
return list;
}
for (File file : files) {
if (file==null) {
continue;
}
if (file.isDirectory()) {
list.addAll(getAllFile(file.getAbsolutePath()));
} else {
list.add(file.getAbsolutePath());
}
}
return list;
}