开发者

Browse Directory option for sftp and ftp

开发者 https://www.devze.com 2023-04-08 17:53 出处:网络
Currently I\'m doing 开发者_如何学编程the functionality for sftp using jsch-0.1.44. I need to add option for the user to browse the directory. So how to get the list of files from the remote server. I

Currently I'm doing 开发者_如何学编程the functionality for sftp using jsch-0.1.44. I need to add option for the user to browse the directory. So how to get the list of files from the remote server. Is there any other open source exists for this functionality ? Please help me


The ChannelSftp class provides the necessary methods to browse a remote directory.

For listing the directory, use channel.ls("."). This returns a vector of LsEntry objects, which you can traverse, print, show in a window, etc.


This example from jsch examples list shows one way to do this.

Look at the code starting from the following line...

if(cmd.equals("ls") || cmd.equals("dir")){


You can use Apache Virtual File System. If you are creating GUI application you can use OtrosVfsBrowser or VFSJFileChooser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号