dav*_*vid 7 java url absolute-path apache-commons-httpclient
我正在尝试使用HttpClient将文件上传/删除到webdav服务器.但是,只要文件名由空格组成,就没有任何工作.我收到一条错误消息"无效的URI ---转义的绝对路径无效".
这个我的URL ="http:// localhost:8080/test file.txt"
private boolean delete(String fileName) {
HttpClient client = new HttpClient();
HttpHost host = new HttpHost(WEBDAV_URL, PORT_NUMBER);
client.getHostConfiguration().setHost(host);
DeleteMethod del = new DeleteMethod(WEBDAV_URL_COMPLETE + fileName);
try {
client.executeMethod(del);
return true;
} catch (HttpException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我应该使用任何方法或URL解析来解决问题
谢谢
编辑,通过用" %20 " 替换空格来找到解决方案.
**
URL.replaceAll("","%20")
**
| 归档时间: |
|
| 查看次数: |
12465 次 |
| 最近记录: |