This commit is contained in:
Looly 2019-09-16 19:00:11 +08:00
parent acb54849dd
commit 0fbede424e

View File

@ -55,6 +55,7 @@ import cn.hutool.core.io.file.LineSeparator;
import cn.hutool.core.io.file.Tailer; import cn.hutool.core.io.file.Tailer;
import cn.hutool.core.io.resource.ResourceUtil; import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.CharUtil; import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.CharsetUtil;
@ -313,14 +314,16 @@ public class FileUtil {
int index = path.lastIndexOf(FileUtil.JAR_PATH_EXT); int index = path.lastIndexOf(FileUtil.JAR_PATH_EXT);
if (index < 0) { if (index < 0) {
// 普通目录 // 普通目录
final List<String> paths = new ArrayList<String>(); final List<String> paths = new ArrayList<>();
final File[] files = ls(path); final File[] files = ls(path);
for (File file : files) { for (File file : files) {
if (file.isFile()) { if (file.isFile()) {
paths.add(file.getName()); paths.add(file.getName());
} }
} }
} else { return paths;
}
// jar文件 // jar文件
path = getAbsolutePath(path); path = getAbsolutePath(path);
// jar文件中的路径 // jar文件中的路径
@ -336,9 +339,6 @@ public class FileUtil {
} }
} }
return new ArrayList<>(0);
}
/** /**
* 创建File对象相当于调用new File()不做任何处理 * 创建File对象相当于调用new File()不做任何处理
* *
@ -357,8 +357,8 @@ public class FileUtil {
* @return File * @return File
*/ */
public static File file(String path) { public static File file(String path) {
if (StrUtil.isBlank(path)) { if (null == path) {
throw new NullPointerException("File path is blank!"); return null;
} }
return new File(getAbsolutePath(path)); return new File(getAbsolutePath(path));
} }
@ -1765,7 +1765,7 @@ public class FileUtil {
*/ */
public static String getName(String filePath) { public static String getName(String filePath) {
if (null == filePath) { if (null == filePath) {
return filePath; return null;
} }
int len = filePath.length(); int len = filePath.length();
if (0 == len) { if (0 == len) {