//定义文件夹路径 wordPath为文件夹的路径 File filedir = new File(wordPath); File[] tempList = filedir.listFiles(); System.out.println("该目录下对象个数:"+tempList.length); for (int i = 0; i < tempList.length; i++) { if (tempList[i].isFile()) { Map<String,Object> filesMap=new HashMap<String, Object>(); filesMap.put("fileUrl", tempList[i].toString().replaceAll("\\\\", "/")); filesMap.put("fileName", tempList[i].getName().toString().replaceAll("\\\\", "/")); //拼接一个对象集合 filesToMerge.add(filesMap); //for循环输出url System.out.println(tempList[i].toString().replaceAll("\\\\", "/")); } } System.out.println(filesToMerge);
java获取文件夹下所有文件
最新推荐文章于 2024-08-03 17:05:14 发布