org.apache.commons.vfs2.FileSystemException: Expecting / to follow the hostname in URI
有没有人知道如何解决这个问题?(很显然我无法更改密码)。这是我正在使用的代码:
String sftpUri = "sftp://" + userName + ":" + password + "@"
+ remoteServerAddress + "/" + remoteDirectory + fileName;
String filepath = localDirectory + fileName;
File file = new File(filepath);
FileObject localFile = manager.resolveFile(file.getAbsolutePath());
FileObject remoteFile = manager.resolveFile(sftpUri, opts);
localFile.copyFrom(remoteFile, Selectors.SELECT_SELF);
sftpUri
。如果您的密码包含@符号,remoteServerAddress
参数会发生什么变化? - Hannesjava.net
中的URLEncoder.encode(...)
。只对用户名和密码进行编码。 - Hannes