mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
ftp.exist空值检查
This commit is contained in:
parent
f279b4a9ac
commit
e0559ec96c
@ -97,6 +97,9 @@ public abstract class AbstractFtp implements Closeable {
|
||||
* @return 是否存在
|
||||
*/
|
||||
public boolean exist(String path) {
|
||||
if (StrUtil.isBlank(path)) {
|
||||
return false;
|
||||
}
|
||||
// 目录验证
|
||||
if (isDir(path)) {
|
||||
return true;
|
||||
|
@ -122,6 +122,11 @@ public class FtpTest {
|
||||
@Ignore
|
||||
public void existFtpTest() throws Exception {
|
||||
try (Ftp ftp = new Ftp("127.0.0.1", 21)) {
|
||||
Console.log(ftp.exist(null));
|
||||
Console.log(ftp.exist(""));
|
||||
Console.log(ftp.exist("."));
|
||||
Console.log(ftp.exist(".."));
|
||||
Console.log(ftp.exist("/"));
|
||||
Console.log(ftp.exist("/test"));
|
||||
Console.log(ftp.exist("/test/"));
|
||||
Console.log(ftp.exist("/test//////"));
|
||||
@ -132,9 +137,7 @@ public class FtpTest {
|
||||
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…
Reference in New Issue
Block a user