X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fnet%2Fsf%2Fopenrocket%2Fdatabase%2FDatabase.java;h=fd901dfa9da216c1c438d32480e87eeb97df4e19;hb=02f3d96a74beac56396117f4c8ea3497134ad139;hp=b7986cb7fed54abd33ead08066204860a1210b72;hpb=cc0359dcfd20fcaca76bbb6ac1138dbc3d3528cb;p=debian%2Fopenrocket diff --git a/src/net/sf/openrocket/database/Database.java b/src/net/sf/openrocket/database/Database.java index b7986cb7..fd901dfa 100644 --- a/src/net/sf/openrocket/database/Database.java +++ b/src/net/sf/openrocket/database/Database.java @@ -5,10 +5,6 @@ import java.io.FileInputStream; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.security.CodeSource; import java.util.AbstractSet; import java.util.ArrayList; import java.util.Collections; @@ -24,6 +20,7 @@ import javax.swing.event.EventListenerList; import net.sf.openrocket.file.Loader; import net.sf.openrocket.util.ChangeSource; +import net.sf.openrocket.util.JarUtil; @@ -182,17 +179,9 @@ public class Database> extends AbstractSet implements if (!dir.endsWith("/")) { dir += "/"; } - - // Find the jar file this class is contained in and open it - URL jarUrl = null; - CodeSource codeSource = Database.class.getProtectionDomain().getCodeSource(); - if (codeSource != null) - jarUrl = codeSource.getLocation(); - if (jarUrl == null) { - throw new IOException("Could not find containing JAR file."); - } - File file = urlToFile(jarUrl); + // Find and open the jar file this class is contained in + File file = JarUtil.getCurrentJarFile(); JarFile jarFile = new JarFile(file); try { @@ -219,22 +208,6 @@ public class Database> extends AbstractSet implements } - static File urlToFile(URL url) { - URI uri; - try { - uri = url.toURI(); - } catch (URISyntaxException e) { - try { - uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), - url.getPath(), url.getQuery(), url.getRef()); - } catch (URISyntaxException e1) { - throw new IllegalArgumentException("Broken URL: " + url); - } - } - return new File(uri); - } - - public void load(File file) throws IOException { if (loader == null) {