[ACCEPTED]-Java: how to get a File from an escaped URL?-escaping
Accepted answer
The File
constructor taking an URI
in combination with URL#toURI()
should work:
URL url = getItSomehow();
File file = new File(url.toURI());
0
URLDecoder.decode(url);//deprecated
URLDecoder.decode(url, "UTF-8"); //use this instead
See related question How do you unescape URLs in Java?
0
AFAIK like this Paths.get(url.toURI()).toFile()
is best, starting with 1 Java 7. See also Converting Java file:// URL to File(...) path, platform independent, including UNC paths.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.