public static URL buildJarUrl(String fileUrlString, String entryPath) throws MalformedURLException { String safeString = makeSafeForJarUrl(fileUrlString); StringBuilder sb = new StringBuilder(); sb.append(safeString); sb.append("!/"); if (entryPath != null) { sb.append(makeSafeForJarUrl(entryPath)); } return new URL("jar", null, -1, sb.toString()); }
public static URL buildJarSafeUrl(File file) throws MalformedURLException { String safe = makeSafeForJarUrl(file.toURI().toString()); return new URL(safe); }