mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
避免重复rename函数,增加新单元测试SshjSftpTest,SftpTest用于测试Sftp类
This commit is contained in:
@@ -737,25 +737,6 @@ public class Ftp extends AbstractFtp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名文件/目录
|
||||
*
|
||||
* @param from 原路径
|
||||
* @param to 目标路径
|
||||
*
|
||||
* @throws FtpException FTP异常
|
||||
*/
|
||||
@Override
|
||||
public void rename(String from, String to) throws FtpException {
|
||||
try {
|
||||
if (!client.rename(from, to)) {
|
||||
throw new FtpException("rename [{}] to [{}] fail", from, to);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new FtpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取FTPClient客户端对象
|
||||
*
|
||||
|
@@ -656,23 +656,6 @@ public class Sftp extends AbstractFtp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名文件/目录
|
||||
*
|
||||
* @param from 原路径
|
||||
* @param to 目标路径
|
||||
*
|
||||
* @throws JschRuntimeException Jsch异常
|
||||
*/
|
||||
@Override
|
||||
public void rename(String from, String to) throws JschRuntimeException {
|
||||
try {
|
||||
getClient().rename(from, to);
|
||||
} catch (SftpException e) {
|
||||
throw new JschRuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程文件
|
||||
*
|
||||
|
@@ -261,23 +261,6 @@ public class SshjSftp extends AbstractFtp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名文件/目录
|
||||
*
|
||||
* @param from 原路径
|
||||
* @param to 目标路径
|
||||
*
|
||||
* @throws FtpException FTP异常
|
||||
*/
|
||||
@Override
|
||||
public void rename(String from, String to) throws FtpException {
|
||||
try {
|
||||
sftp.rename(from, to);
|
||||
} catch (IOException e) {
|
||||
throw new FtpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
IoUtil.close(this.session);
|
||||
|
Reference in New Issue
Block a user