|
@@ -330,7 +330,6 @@ public class FileUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
* 创建父目录
|
|
|
*/
|
|
@@ -711,10 +710,10 @@ public class FileUtil {
|
|
|
* 获取所有同一类型的文件列表。
|
|
|
*
|
|
|
* @param rootPath 文件 File 路径。
|
|
|
- * @param type 文件类型不带点,如 txt。
|
|
|
+ * @param type 文件类型不带点,如 txt。
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public static List<String> listAbsolutePathByType(String rootPath, String type) {
|
|
|
+ public static List<String> listAbsolutePathByTypeAndLength(String rootPath, String type, int length) {
|
|
|
List<String> result = new LinkedList<>();
|
|
|
File rootFile = new File(rootPath);
|
|
|
|
|
@@ -722,7 +721,7 @@ public class FileUtil {
|
|
|
throw new RuntimeException("FileUtil.listAbsolutePathByType() 文件 " + rootPath + " 不存在!");
|
|
|
}
|
|
|
|
|
|
- if (rootFile.isFile() && rootFile.getName().endsWith(type)) {
|
|
|
+ if (rootFile.isFile() && rootFile.getName().endsWith(type) && rootFile.getName().length() == length) {
|
|
|
return new ArrayList<>(Collections.singletonList(rootPath));
|
|
|
}
|
|
|
|
|
@@ -730,7 +729,7 @@ public class FileUtil {
|
|
|
File[] children = rootFile.listFiles();
|
|
|
if (children != null) {
|
|
|
for (File child : children) {
|
|
|
- result.addAll(listAbsolutePathByType(child.getAbsolutePath(), type));
|
|
|
+ result.addAll(listAbsolutePathByTypeAndLength(child.getAbsolutePath(), type, length));
|
|
|
}
|
|
|
}
|
|
|
}
|