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

Use static helper method for all space character issues

parent 6dead1ee
No related branches found
No related tags found
1 merge request!36Bug/file path issues
package de.tudresden.inf.mci.brailleplot.configparser; package de.tudresden.inf.mci.brailleplot.configparser;
import de.tudresden.inf.mci.brailleplot.util.UrlHelper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -265,11 +266,7 @@ public abstract class ConfigurationParser { ...@@ -265,11 +266,7 @@ public abstract class ConfigurationParser {
* @return The String representation of the path of a URL where the leading {@literal "}file:{@literal "} prefix is stripped. * @return The String representation of the path of a URL where the leading {@literal "}file:{@literal "} prefix is stripped.
*/ */
private static String getPath(final URL url) throws ConfigurationParsingException { private static String getPath(final URL url) throws ConfigurationParsingException {
try { String urlString = UrlHelper.getPathString(url);
String urlString = URLDecoder.decode(url.getPath(), "UTF-8"); return urlString.replaceAll("^file:", "");
return urlString.replaceAll("^file:", "");
} catch (UnsupportedEncodingException e) {
throw new ConfigurationParsingException("Could not decode URL", e);
}
} }
} }
...@@ -190,7 +190,7 @@ public final class GeneralResource { ...@@ -190,7 +190,7 @@ public final class GeneralResource {
throw new IllegalStateException("Not running from jar."); throw new IllegalStateException("Not running from jar.");
} }
URL jarUrl = getClassRef().getProtectionDomain().getCodeSource().getLocation(); URL jarUrl = getClassRef().getProtectionDomain().getCodeSource().getLocation();
String jarPath = URLDecoder.decode(jarUrl.getPath(), "UTF-8"); String jarPath = UrlHelper.getPathString(jarUrl);
File jarFile = new File(jarPath); File jarFile = new File(jarPath);
return new JarFile(jarFile); return new JarFile(jarFile);
} catch (Exception e) { } catch (Exception e) {
......
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