mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
ftp.exist分支优化
This commit is contained in:
parent
feb62498fd
commit
f279b4a9ac
@ -100,13 +100,15 @@ public abstract class AbstractFtp implements Closeable {
|
||||
// 目录验证
|
||||
if (isDir(path)) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
if (CharUtil.isFileSeparator(path.charAt(path.length() - 1))) {
|
||||
return false;
|
||||
}
|
||||
final String fileName = FileUtil.getName(path);
|
||||
if (".".equals(fileName) || "..".equals(fileName)) {
|
||||
return false;
|
||||
}
|
||||
// 文件验证
|
||||
final String fileName = FileUtil.getName(path);
|
||||
final String dir = StrUtil.removeSuffix(path, fileName);
|
||||
final List<String> names;
|
||||
try {
|
||||
|
@ -122,14 +122,19 @@ public class FtpTest {
|
||||
@Ignore
|
||||
public void existFtpTest() throws Exception {
|
||||
try (Ftp ftp = new Ftp("127.0.0.1", 21)) {
|
||||
Console.log(ftp.exist("/test/"));
|
||||
Console.log(ftp.exist("/test"));
|
||||
Console.log(ftp.exist("/test/"));
|
||||
Console.log(ftp.exist("/test//////"));
|
||||
Console.log(ftp.exist("/test/.."));
|
||||
Console.log(ftp.exist("/test/."));
|
||||
Console.log(ftp.exist("/file1"));
|
||||
Console.log(ftp.exist("/file1/"));
|
||||
Console.log(ftp.exist("///////////"));
|
||||
Console.log(ftp.exist("./"));
|
||||
Console.log(ftp.exist("./file1"));
|
||||
Console.log(ftp.exist("."));
|
||||
Console.log(ftp.exist("./2/3/4/.."));
|
||||
Console.log(ftp.ls("./2/3/4/.."));
|
||||
Console.log(ftp.pwd());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user