Question

I have no idea how to reference a file from the root directory. Currently, any path in the URI is child of the user directory. I'm trying to access /var/www with this:

sftp://user:password@host/var/www

but it's ineffective.

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

Solution

I've found a solution.

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:password@host/var/www", options);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top