URLUtils { public static String resolveRelativePath(URL archiveFileURL) throws NullPointerException { String path = archiveFileURL.getPath(); if (path.contains(SeparatorConstants.ARCHIVE_ENTITY)) { String relativePath = StringUtils.substringAfterLast(path, SeparatorConstants.ARCHIVE_ENTITY); return decode(relativePath); } return null; }  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 testResolveRelativePath() throws MalformedURLException { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); URL resourceURL = ClassLoaderUtils.getClassResource(classLoader, String.class); String expectedPath = "java/lang/String.class"; String relativePath = URLUtils.resolveRelativePath(resourceURL); Assert.assertEquals(expectedPath, relativePath); File rtJarFile = new File(SystemUtils.JAVA_HOME, "lib/rt.jar"); resourceURL = rtJarFile.toURI().toURL(); relativePath = URLUtils.resolveRelativePath(resourceURL); Assert.assertNull(relativePath); }