connect to SFTP using java

后端 未结 6 1718
野趣味
野趣味 2021-01-07 09:33

I need help with connection to SFTP server? Does anybody have working code?

I found something like this

package test.JSch;

import com.jcraft.jsch.*;         


        
6条回答
  •  感动是毒
    2021-01-07 10:14

    You can use Apache commons VFS

    FileSystemManager fsManager = VFS.getManager();
    FileObject remoteFile = fsManager.resolveFile("sftp://myusername:mypassword@somehost/pub/downloads/somefile.tgz" );
    InputStream in = remoteFile.getContent().getInputStream();
    

提交回复
热议问题