Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Commons VFS:SFTP URL语法,同时连接到使用Open SSH运行的Windows服务器_Java_Ssh_Apache Commons Vfs - Fatal编程技术网

Java Commons VFS:SFTP URL语法,同时连接到使用Open SSH运行的Windows服务器

Java Commons VFS:SFTP URL语法,同时连接到使用Open SSH运行的Windows服务器,java,ssh,apache-commons-vfs,Java,Ssh,Apache Commons Vfs,我们使用Commons VFS API在不同服务器之间进行文件传输。该代码非常适合Linux服务器 但是Windows服务器存在URL语法问题。我们尝试了下面的URL类型列表,但所有这些类型都导致了无效的绝对URI错误 sftp://user@IP:C:\temp sftp://user@IP/C:\temp sftp://user@IP\C:\temp stfp://user@IP/temp--导致无法确定文件类型 所有这些错误在我们脑海中引发了另一个疑问,即VFS是否支持通过SFTP连接到W

我们使用Commons VFS API在不同服务器之间进行文件传输。该代码非常适合Linux服务器

但是Windows服务器存在URL语法问题。我们尝试了下面的URL类型列表,但所有这些类型都导致了无效的绝对URI错误

sftp://user@IP:C:\temp

sftp://user@IP/C:\temp

sftp://user@IP\C:\temp

stfp://user@IP/temp--导致无法确定文件类型

所有这些错误在我们脑海中引发了另一个疑问,即VFS是否支持通过SFTP连接到Windows文件系统


非常感谢您在这方面提供的帮助。

您需要使用正斜杠将主机与路径以及不同的路径元素分开

指定dos驱动器的方式取决于您使用的SFTP服务器。其中一些使用cygwin路径,如/cygdrive/c/temp,其他一些使用/c/temp,还有一些使用基本路径下的某个基本目录

我不确定是否有一个允许驱动器号使用冒号,但无论如何,如果您介意,您需要使用
%3a
(十六进制代码)转义
(冒号):

如果您不想自己引用URL中所有可能的字符,可以使用中建议的URI类:(但需要确保以
/
(斜杠)开头的
路径
字符串将其设置为绝对值。)

或者,当您不想转换本地路径时,可以使用:

String path = new File("C:\\temp").toURI().getPath();
URI uri2 = new URI("sftp", "user:p@ssword", "127.0.0.1", -1, path, null, null);
fsm.resolveFile(uri2.toString(), opts);
请让我知道哪个路径语法有效

URI uri1 = new URI("sftp", "user:p@ssword", "127.0.0.1", -1, "/C:/temp", null, null);
fsm.resolveFile(uri1.toString(), opts);
String path = new File("C:\\temp").toURI().getPath();
URI uri2 = new URI("sftp", "user:p@ssword", "127.0.0.1", -1, path, null, null);
fsm.resolveFile(uri2.toString(), opts);