java实现获取文件夹下所有文件的路径
/**
* 获取文件夹下所有文件的路径
*
* @param folderPath
* @return
*/
public static List<String> getFilePath(String folderPath) {
File folder = new File(folderPath);
List<String> filePathList = new ArrayList<>();
String rootPath;
if (folder.exists()) {
String[] fileNameList = folder.list();
if (null != fileNameList && fileNameList.length > 0) {
if (folder.getPath().endsWith(File.separator)) {
rootPath = folder.getPath();
} else {
rootPath = folder.getPath() + File.separator;
}
for (String fileName : fileNameList) {
filePathList.add(rootPath + fileName);
}
}
}
return filePathList;
}
版权声明:本文为Crezfikbd原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。