Developer404
Developer404

Reputation: 5972

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

Upvotes: 0

Views: 1633

Answers (3)

KrzyH
KrzyH

Reputation: 4326

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

Upvotes: 1

Paŭlo Ebermann
Paŭlo Ebermann

Reputation: 74790

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.

Upvotes: 1

Raghuram
Raghuram

Reputation: 52655

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")){

Upvotes: 1

Related Questions