Search code examples
javasftpedtftpj

Preserving modified timestamp of file while uploading to SFTP


I need to preserve modified timestamp of my file while uploading it to SFTP site.

I am using com.enterprisedt.net.ftp.ssh.SSHFTPclient for the transfer.

Please let me know if there is any way.


Solution

  • Call SSHFTPClient.setModTime after the upload.

    sshFtpClient.setModTime(remotePath, new Date(new File(localPath).lastModified());