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

Fix loadJarFile() for paths containing spaces

parent b15fb375
No related branches found
No related tags found
1 merge request!36Bug/file path issues
...@@ -9,6 +9,7 @@ import java.io.FileNotFoundException; ...@@ -9,6 +9,7 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
...@@ -188,7 +189,9 @@ public final class GeneralResource { ...@@ -188,7 +189,9 @@ public final class GeneralResource {
if (!isRunFromCompiledJar()) { if (!isRunFromCompiledJar()) {
throw new IllegalStateException("Not running from jar."); throw new IllegalStateException("Not running from jar.");
} }
File jarFile = new File(getClassRef().getProtectionDomain().getCodeSource().getLocation().getPath()); URL jarUrl = getClassRef().getProtectionDomain().getCodeSource().getLocation();
String jarPath = URLDecoder.decode(jarUrl.getPath(), "UTF-8");
File jarFile = new File(jarPath);
return new JarFile(jarFile); return new JarFile(jarFile);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Error while retrieving JarFile reference.", e); throw new RuntimeException("Error while retrieving JarFile reference.", 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