java - SFTP - JSch rename file being dowloaded -


i trying develop program retrieve set of files sftp server local directory.

i use jsch library this.

the files downloaded get method.

channelsftp connection = connect(host, port, user, password); connection.get(filename, localfolder, null, mode); 

the business requirement if file not downloaded, can not retrieve local directory.

how can rename file being downloaded in local directory until download not finished?

after download finished, rename file real filename (filename of server sftp)

use full file path in dst argument of .get, including (temporary) file name, not directory path.

connection.get(filename, localfolder + "/tempname", null, mode); 

rename file after .get finishes, using file.renameto().


Comments