I am trying to upload/delete a file to webdav server using HttpClient. However, none is working whenever I have a file name consist of space . I got a error message saying "INVALID URI--- Escaped absolute path not valid".
this my 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;
}
}
is there any method or URL parse should I use to fix the problem
thanks
EDIT, FOUND the solution by replace space with "%20".
**
URL.replaceAll(" ","%20")
**
I used this and get what I want...
URL.replaceAll(" ","%20")
use java.net.URLEncoder.encode
or replace your spaces with '+'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With