1 /**
2 * @Author:
3 * @Description:获取某个目录下所有直接下级文件,不包括目录下的子目录的下的文件,所以不用递归获取
4 * @Date:
5 */
6 public static List<String>
getFiles(String path) {
7 List<String> files =
new ArrayList<String>
();
8 File file =
new File(path);
9 File[] tempList =
file.listFiles();
10
11 for (
int i = 0; i < tempList.length; i++
) {
12 if (tempList[i].isFile()) {
13 files.add(tempList[i].toString());
14 //文件名,不包含路径
15 //String fileName = tempList[i].getName();
16 }
17 if (tempList[i].isDirectory()) {
18 //这里就不递归了,
19 }
20 }
21 return files;
22 }
转载于:https://www.cnblogs.com/huzi007/p/11360736.html
相关资源:java中遍历某个目录下的所有文件及文件夹中的文件