}
public static URI toURI(String localPath) {
+ return toURI(localPath, true);
+ }
+
+ private static URI toURI(String localPath, boolean convertSpaces) {
try {
String p = FileUtil.toSystemIndependentName(localPath);
if (!p.startsWith("/")) {
if (p.startsWith("//")) {
p = "//" + p;
}
- return new URI("file", null, p.replaceAll(" ", "%20"), null);
+ return new URI("file", null, convertSpaces? p.replaceAll(" ", "%20") : p, null);
}
catch (URISyntaxException e) {
throw new Error(e);
}
public static File convertToFile(final URI uri) {
- return new File(toURI(uri.getPath()));
+ return new File(toURI(uri.getPath(), false));
}
}