mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add rename
This commit is contained in:
@@ -403,6 +403,15 @@ public class CommonsFtp extends AbstractFtp {
|
|||||||
return ftpFiles;
|
return ftpFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rename(String oldPath, String newPath) {
|
||||||
|
try {
|
||||||
|
return this.client.rename(oldPath, newPath);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new IORuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mkdir(final String dir) throws IORuntimeException {
|
public boolean mkdir(final String dir) throws IORuntimeException {
|
||||||
try {
|
try {
|
||||||
|
@@ -127,6 +127,15 @@ public interface Ftp extends Closeable {
|
|||||||
*/
|
*/
|
||||||
List<String> ls(String path);
|
List<String> ls(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重命名文件
|
||||||
|
*
|
||||||
|
* @param oldPath 旧文件名(或路径)
|
||||||
|
* @param newPath 新文件名(或路径)
|
||||||
|
* @return 是否重命名成功
|
||||||
|
*/
|
||||||
|
boolean rename(String oldPath, String newPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除指定目录下的指定文件
|
* 删除指定目录下的指定文件
|
||||||
*
|
*
|
||||||
|
@@ -328,6 +328,16 @@ public class JschSftp extends AbstractFtp {
|
|||||||
return entryList;
|
return entryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rename(String oldPath, String newPath) {
|
||||||
|
try {
|
||||||
|
getClient().rename(oldPath, newPath);
|
||||||
|
} catch (final SftpException e) {
|
||||||
|
throw new SshException(e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mkdir(final String dir) {
|
public boolean mkdir(final String dir) {
|
||||||
if (isDir(dir)) {
|
if (isDir(dir)) {
|
||||||
|
@@ -188,6 +188,16 @@ public class SshjSftp extends AbstractFtp {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rename(String oldPath, String newPath) {
|
||||||
|
try {
|
||||||
|
sftp.rename(oldPath, newPath);
|
||||||
|
return containsFile(newPath);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new FtpException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean delFile(final String path) {
|
public boolean delFile(final String path) {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user