Ftp 如何使用Apache Common vfs列出文件目录/文件

Ftp 如何使用Apache Common vfs列出文件目录/文件,ftp,file-transfer,jsch,apache-commons-vfs,Ftp,File Transfer,Jsch,Apache Commons Vfs,我刚刚使用Apache Common vfs, 我成功连接到服务器 我已经看过文档了,但我被困在这段代码里了。 如何列出目录/文件 .... Session session = null; FileSystemManager fsManager = null; FileSystem fs = null; try { String host = "host_here"; int port = 22;

我刚刚使用Apache Common vfs, 我成功连接到服务器 我已经看过文档了,但我被困在这段代码里了。 如何列出目录/文件

....
Session session = null;
        FileSystemManager fsManager = null;
        FileSystem fs = null;
        try {
            String host = "host_here";
            int port = 22;

            String userStr = "user_here";
            char [] username = userStr.toCharArray();

            String passStr = "password_here";
            char [] password = passStr.toCharArray();

            session = SftpClientFactory.createConnection(host, port, username, password, null);
            //session.connect();

            System.out.println("Connected to the server");

            FileSystemOptions opts = new FileSystemOptions();
            fsManager = VFS.getManager();
            FileObject file = fsManager.resolveFile("ftp://"+userStr+":"+passStr+"@"+host+"/home/", opts);    

            // .... whats next i do here? .....

        } catch (Exception e) {
            session.disconnect();
            e.printStackTrace();
        }
...
请帮帮我,
之前谢谢:)

可以使用方法显示文件列表

FileSystemOptions opts=newfilesystemoptions();
fsManager=VFS.getManager();
//列出该目录中的所有文件。尝试给出目录路径
FileObject localFileObject=fsManager.resolveFile(“ftp://“+userStr+”:“+passStr+”@“+host+”/home”);
FileObject[]children=localFileObject.getChildren();
for(int i=0;i

我的建议是使用最适合SFTP操作的框架。由于这个
apachecommonvfs
固有地使用了这个框架。JSCH

会大大降低复杂性,谢谢你srinivas,现在我使用JSCH:D,但是我想知道,如何将目录(而不是文件)保存到目标目录?你是说创建新目录还是保存一个目录,其中已经有一些文件?是的,像这样。有可能吗?
FileSystemOptions opts = new FileSystemOptions();
fsManager = VFS.getManager();

// List all the files in that directory.Try to give the directory path  
FileObject localFileObject=fsManager.resolveFile("ftp://"+userStr+":"+passStr+"@"+host+"/home");
FileObject[] children = localFileObject.getChildren();
for ( int i = 0; i < children.length; i++ ){
    System.out.println( children[ i ].getName().getBaseName() );
}
// End of List Files.

FileObject file = fsManager.resolveFile("ftp://"+userStr+":"+passStr+"@"+host+"/home/", opts);