- /**child.toString().matches(".+\.txt")
* 递归读取文件路径下的所有文件
*
* @param path
* @param fileNameList
* @return
*/
public static ArrayList<String> readFiles1(String path, ArrayList<String> fileNameList) {
File file = new File(path);
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
readFiles1(files[i].getPath(), fileNameList);
} else {
String path1 = files[i].getPath();
String fileName = path1.substring(path1.lastIndexOf("\") + 1);
fileNameList.add(fileName);
}
}
} else {
String path1 = file.getPath();
String fileName = path1.substring(path1.lastIndexOf("\") + 1);
fileNameList.add(fileName);
}
return fileNameList;
}