I'm trying to retrieve a file from a server using SFTP (as opposed to FTPS) using Java. How can I do this?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Try edtFTPj/PRO, a mature, robust SFTP client library that supports connection pools and asynchronous operations. Also supports FTP and FTPS so all bases for secure file transfer are covered.
Here is the complete source code of an example using JSch without having to worry about the ssh key checking.
I found complete working example for SFTP in java using JSCH API http://kodehelp.com/java-program-for-uploading-file-to-sftp-server/
Though answers above were very helpful, I've spent a day to make them work, facing various exceptions like "broken channel", "rsa key unknown" and "packet corrupt".
Below is a working reusable class for SFTP FILES UPLOAD/DOWNLOAD using JSch library.
Upload usage:
Download usage:
The class code: