/**
* 迭代取文件列表
*
* @param fileList
* @return
*/
public static List getFileList(String strPath) {
File fileDir = new File(strPath);
if (null != fileDir && fileDir.isDirectory()) {
File[] files = fileDir.listFiles();
if (null != files) {
for (int i = 0; i < files.length; i++) {
// 如果是文件夹 继续读取
if (files[i].isDirectory()) {
getFileList(files[i].getAbsolutePath());
} else {
String strFileName = files[i].getAbsolutePath();
if (null != strFileName && !strFileName.endsWith(".jar") && !strFileName.endsWith(".cmd")
&& !strFileName.endsWith(".xlsx")) {
System.out.println("---" + strFileName);
fileList.add(files[i]);
}
}
}
} else {
if (null != fileDir) {
String strFileName = fileDir.getAbsolutePath();
// 排除jar cmd 和 xlsx (根据需求需要)
if (null != strFileName && !strFileName.endsWith(".jar") && !strFileName.endsWith(".cmd")
&& !strFileName.endsWith(".xlsx")) {
System.out.println("---" + strFileName);
fileList.add(fileDir);
}
}
}
}
// 定义的全去文件列表的变量
return fileList;
}