/** * @Author: * @Description:获取某个目录下所有直接下级文件,不包括目录下的子目录的下的文件,所以不用递归获取 * @Date: */ public static List<String> getFiles(String path) { List<String> files = new ArrayList<String>(); File file = new File(path); File[] tempList = file.listFiles(); for (int i = 0; i < tempList.length; i++) { if (tempList[i].isFile()) { files.add(tempList[i].toString()); //文件名,不包含路径 //String fileName = tempList[i].getName(); } if (tempList[i].isDirectory()) { //这里就不递归了, } } return files; }
转载于:https://www.cnblogs.com/shaosks/p/9625878.html
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/101433.html原文链接:https://javaforall.net