2012-11-21 97 views
1

通过FTP URI导航到根目录我不知道如何从根目录引用文件。目前,URI中的任何路径都是用户目录的子节点。我试图访问/ var/www与此:使用Apache Commons VFS

sftp://user:[email protected]/var/www 

但它是无效的。

org.apache.commons.vfs2.FileNotFolderException: Could not list the contents of "sftp://user:***@host/var/www" because it is not a folder. 

回答

2

我找到了解决方案。

SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance(); 
FileSystemOptions options = new FileSystemOptions(); 
builder.getKnownHosts(options); 
builder.setUserDirIsRoot(options, false); 
builder.setTimeout(options, 5000); 

FileObject directory = manager.resolveFile("sftp://user:[email protected]/var/www", options); 
+0

工作就像一个魅力!万分感谢 –

相关问题