URLUtils { public static File resolveArchiveFile(URL archiveFileURL, String archiveFileExtensionName) throws NullPointerException { String archiveFilePath = archiveFileURL.getPath(); String prefix = ":/"; boolean hasJarEntryPath = archiveFilePath.contains(SeparatorConstants.ARCHIVE_ENTITY); String suffix = hasJarEntryPath ? SeparatorConstants.ARCHIVE_ENTITY : archiveFileExtensionName; String jarPath = StringUtils.substringBetween(archiveFilePath, prefix, suffix); File archiveFile = null; if (StringUtils.isNotBlank(jarPath)) { jarPath = PathConstants.SLASH + URLUtils.decode(jarPath); archiveFile = new File(jarPath); archiveFile = archiveFile.exists() ? archiveFile : null; } return archiveFile; }  static String resolveRelativePath(URL archiveFileURL); static File resolveArchiveFile(URL archiveFileURL, String archiveFileExtensionName); @Nonnull static Map<String, List<String>> resolveParametersMap(String url); static String resolvePath(final String path); static String encode(String value, String encoding); static String encode(String value); static String decode(String value); static String decode(String value, String encoding); static boolean isDirectoryURL(URL url); static boolean isJarURL(URL url); static String buildURI(String... paths);  }
@Test public void testResolveArchiveFile() { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); URL resourceURL = ClassLoaderUtils.getClassResource(classLoader, String.class); File archiveFile = URLUtils.resolveArchiveFile(resourceURL, FileSuffixConstants.JAR); Assert.assertTrue(archiveFile.exists()); }