开发者

Browse Directory option for sftp and ftp

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜