I am using JSch to connect to SFTP in a website which is made from GWT.
I had read a little example of sftpChannel.get()
, sftpChannel.rename()
, sftpChannel.rm()
But I didn't find a solution that copy a file from remote server a
directory to remote server b
directory.
For example, I want to copy file from /appl/user/home/test/temp
to /appl/user/home/test/
. Filename = abc.jpg
.
I stunned here for few hours since most of the solution from network is getting file from remote server to local, or uploading file from local to remote server.
String existingfile = "abc.jpg";
String newfile = "123.jpg";
FileDirectory = "/appl/user/home/test/";
sftp.cd(FileDirectory+"temp/");
sftp.rename(newfile, FileDirectory+newfile);
Let's say, abc.jpg
is existing in /appl/user/home/test/
And I upload a 123.jpg
in /appl/user/home/test/temp/
.
Now, I want to move 123.jpg
to /appl/user/home/test/
and remove abc.jpg
in /appl/user/home/test/
.
What should I do?