![](/img/trans.png)
[英]How to move file from one folder to another folder on remote sftp server providing the filename dynamically using Java Config?
[英]How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
我一直在嘗試將遠程服務器中的幾個選定文件(在執行了幾次檢查之后)復制到同一個遠程服務器,使用:
File localFile = new File(srcPath);
sftpChannel.put(localFile.getAbsolutePath(),localFile.getName());
我什至嘗試使用get()
方法將這些選定的文件復制到我的本地計算機。
有人可以幫忙嗎?
核心 SFTP 協議不支持復制遠程文件。
協議有copy-file
/ copy-data
擴展草案。 但只有少數 SFTP 服務器支持這些。 在最廣泛使用的 OpenSSH SFTP 服務器中,只有最近的9.0 版本才支持它。 其他服務器例如ProFTPD mod_sftp
和 Bitvise SFTP 服務器。
JSch 庫不支持擴展。
備擇方案:
cp
命令(或服務器操作系統的等效命令)。Exec.java
示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.