How to preserve modification time when uploading a file with JSch put to SFTP server

Viewed 321

In sftp you may use put -p to preserve the last modification timestamp. How can I do that in Java using JSch?

I use the function put(source, destination, mode), but cannot find a value of mode similar to -p in sftp.

A current timestamp is put on the file at the destination. I want the timestamp from the source.

1 Answers

JSch won't do it for you. You have to explicitly update the remote timestamp after the upload using ChannelSftp.setMtime.

Related