Skip to content
Snippets Groups Projects
Commit 6dead1ee authored by Georg Graßnick's avatar Georg Graßnick :thinking:
Browse files

Fix spaces in getOrExportResourceFile()

parent 5123d579
No related branches found
No related tags found
1 merge request!36Bug/file path issues
......@@ -142,7 +142,7 @@ public final class GeneralResource {
* @param path Absolute classpath pointing to jar resource. Omit the leading "/". If this point to a resource directory the directory and all contents are exported.
* @return A File instance representing the resource on the file system.
*/
public static File getOrExportResourceFile(final String path) {
public static synchronized File getOrExportResourceFile(final String path) {
if (isRunFromCompiledJar()) {
try {
JarFile jar = openJarFile();
......@@ -179,7 +179,7 @@ public final class GeneralResource {
} else {
Class cl = getClassRef();
URL resource = cl.getResource("/" + path); // preceding slash for absolute classpath reference
String directoryPath = resource.getPath();
String directoryPath = UrlHelper.getPathString(resource);
return new File(directoryPath);
}
}
......
package de.tudresden.inf.mci.brailleplot.util;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
/**
* This class offers static helper methods for working wth {@link URL} objects.
* @author Georg Graßnick
* @version 2019.09.27
*/
public final class UrlHelper {
private UrlHelper() { }
/**
* Get the string representation of the path of a {@link URL}.
* For example, spaces are taken care of here.
* @param url The {@link URL} to analyze.
* @return The string representation of the path of the {@link URL}.
*/
public static String getPathString(final URL url) {
return URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment