Browse Source

fix ftpFiles length Exception

Ruler 5 years ago
parent
commit
c0c3395296
1 changed files with 2 additions and 2 deletions
  1. 2 2
      hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java

+ 2 - 2
hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java

@@ -294,11 +294,11 @@ public class Ftp extends AbstractFtp {
 			return ListUtil.empty();
 		}
 
-		final List<FTPFile> result = new ArrayList<>(ftpFiles.length - 2);
+		final List<FTPFile> result = new ArrayList<>(ftpFiles.length - 2 <= 0 ? ftpFiles.length : ftpFiles.length - 2);
 		String fileName;
 		for (FTPFile ftpFile : ftpFiles) {
 			fileName = ftpFile.getName();
-			if (false == StrUtil.equals(".", fileName) && false == StrUtil.equals("..", fileName)) {
+			if (!StrUtil.equals(".", fileName) && !StrUtil.equals("..", fileName)) {
 				if (null == filter || filter.accept(ftpFile)) {
 					result.add(ftpFile);
 				}