Convert a URL of the form war:file:... to jar:file:... . @param warUrl The WAR URL to convert @return The equivalent JAR URL @throws IOException If the conversion fails
(URL warUrl)
| 221 | * @throws IOException If the conversion fails |
| 222 | */ |
| 223 | public static URL warToJar(URL warUrl) throws IOException { |
| 224 | // Assumes that the spec is absolute and starts war:file:/... |
| 225 | String file = warUrl.getFile(); |
| 226 | if (file.contains("*/")) { |
| 227 | file = file.replaceFirst("\\*/", "!/"); |
| 228 | } else if (PATTERN_CUSTOM != null) { |
| 229 | file = file.replaceFirst(PATTERN_CUSTOM.pattern(), "!/"); |
| 230 | } |
| 231 | URI uri; |
| 232 | try { |
| 233 | uri = new URI("jar", file, null); |
| 234 | } catch (URISyntaxException e) { |
| 235 | throw new IOException(e); |
| 236 | } |
| 237 | return uri.toURL(); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | /** |