@Override public URL getUrl() throws MalformedURLException { if (this.url != null) { return this.url; } return this.jarFile.getUrl(); }
private boolean isUrlInJarFile(URL url, JarFile jarFile) throws MalformedURLException { // Try the path first to save building a new url string each time return url.getPath().startsWith(jarFile.getUrl().getPath()) && url.toString().startsWith(jarFile.getUrlString()); }
String getUrlString() throws MalformedURLException { if (this.urlString == null) { this.urlString = getUrl().toString(); } return this.urlString; }
/** * Return a {@link URL} for this {@link JarEntry}. * @return the URL for the entry * @throws MalformedURLException if the URL is not valid */ URL getUrl() throws MalformedURLException { return new URL(this.jarFile.getUrl(), getName()); }
private URL buildJarFileUrl() { try { String spec = this.jarFile.getUrl().getFile(); if (spec.endsWith(SEPARATOR)) { spec = spec.substring(0, spec.length() - SEPARATOR.length()); } if (spec.indexOf(SEPARATOR) == -1) { return new URL(spec); } return new URL("jar:" + spec); } catch (MalformedURLException ex) { throw new IllegalStateException(ex); } }