Followed this codeSFTP拋出異常,說無效的絕對URI
我得到這個錯誤,我在節目中所做的唯一的變化是我硬編碼參數作爲
String hostName = "122.183.217.133" ;
String username = "root";
String password = "something";
String localFilePath = "C://Sample.jpg";
String remoteFilePath = "/var/www/html/intranetupload/uploads/Sample.jpg";
Jun 25, 2012 2:52:18 PM org.apache.commons.vfs2.VfsLog info
INFO: Using "C:\DOCUME~1\MEENAK~1.DCK\LOCALS~1\Temp\vfs_cache" as temporary files store.
Exception in thread "main" java.lang.RuntimeException: org.apache.commons.vfs2.FileSystemException: Invalid absolute URI "sftp://root:***@122.183.217.133:22/var/www/html/intranetupload/uploads/Sample1.jpg".
at sftp.sample.Main.delete(Main.java:120)
at sftp.sample.Main.main(Main.java:36)
Caused by: org.apache.commons.vfs2.FileSystemException: Invalid absolute URI "sftp://root:***@122.183.217.133:22/var/www/html/intranetupload/uploads/Sample1.jpg".
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:61)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:693)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:621)
at sftp.sample.Main.delete(Main.java:111)
... 1 more
Caused by: org.apache.commons.vfs2.FileSystemException: Expecting/to follow the hostname in URI "sftp://root:***@122.183.217.133:22/var/www/html/intranetupload/uploads/Sample1.jpg".
at org.apache.commons.vfs2.provider.HostFileNameParser.extractToPath(HostFileNameParser.java:155)
at org.apache.commons.vfs2.provider.URLFileNameParser.parseUri(URLFileNameParser.java:50)
at org.apache.commons.vfs2.provider.AbstractFileProvider.parseUri(AbstractFileProvider.java:188)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:57)
... 4 more
我不沒有服務器的域名。我所擁有的是一臺ubuntu機器,其IP /用戶名和密碼是已知的。 我的工作需要刪除該遠程Ubuntu機器中的文件。
你能幫我解決這個錯誤嗎?
您是否使用與本教程中完全相同的代碼? – AlexS
是的。除了硬編碼的論點。我使用了相同的 – Meenakshi