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.
精彩评论