[尝试使用JSch API重命名文件/文件夹,因为Shell命令无法执行它们。 mkdir和rmdir运行正常。
JDK版本-11。
JSch版本-0.1.55。
任何线索都会受到赞赏。预先感谢。
使用以下代码。
ChannelExec execChannel = null;
try {
execChannel = (ChannelExec) session.openChannel("exec");
execChannel.connect();
execChannel.setCommand("rename dir1 dir2");
execChannel.start();
} catch (JSchException ex) {
throw new IOException(ex);
} finally {
if (execChannel != null) {
execChannel.disconnect();
}
}
如果您使用的是Jsch,我相信远程主机是一个类似Unix的系统。在Unix中没有命令rename
。请改用mv
。