@Test public void testURLWithInvalidURIChars() throws MalformedURLException { URL url = new URL("file: String actual = (new FileProvider()).filePathFromURL(url); assertThat( actual, PlatformUtil.onWindows() ? matchesPattern("\\A/[A-Z]:/\\[Eclipse\\]/File.jar\\z") : equalTo("/[Eclipse]/File.jar")); }
public String filePathFromURL(URL url) { if (url == null) { throw new IllegalArgumentException("url is null"); } try { URI uri = new File(URLDecoder.decode(url.getPath(), "UTF-8")).toURI(); return uri.getPath(); } catch (UnsupportedEncodingException e) { Assertions.UNREACHABLE(); return null; } }
FileProvider { public String filePathFromURL(URL url) { if (url == null) { throw new IllegalArgumentException("url is null"); } try { URI uri = new File(URLDecoder.decode(url.getPath(), "UTF-8")).toURI(); return uri.getPath(); } catch (UnsupportedEncodingException e) { Assertions.UNREACHABLE(); return null; } } }
FileProvider { public String filePathFromURL(URL url) { if (url == null) { throw new IllegalArgumentException("url is null"); } try { URI uri = new File(URLDecoder.decode(url.getPath(), "UTF-8")).toURI(); return uri.getPath(); } catch (UnsupportedEncodingException e) { Assertions.UNREACHABLE(); return null; } }  }
FileProvider { public String filePathFromURL(URL url) { if (url == null) { throw new IllegalArgumentException("url is null"); } try { URI uri = new File(URLDecoder.decode(url.getPath(), "UTF-8")).toURI(); return uri.getPath(); } catch (UnsupportedEncodingException e) { Assertions.UNREACHABLE(); return null; } }  Module getJarFileModule(String fileName); Module getJarFileModule(String fileName, ClassLoader loader); URL getResource(String fileName); URL getResource(String fileName, ClassLoader loader); File getFile(String fileName); File getFile(String fileName, ClassLoader loader); File getFileFromClassLoader(String fileName, ClassLoader loader); InputStream getInputStreamFromClassLoader(String fileName, ClassLoader loader); Module getJarFileFromClassLoader(String fileName, ClassLoader loader); String filePathFromURL(URL url); }
FileProvider { public String filePathFromURL(URL url) { if (url == null) { throw new IllegalArgumentException("url is null"); } try { URI uri = new File(URLDecoder.decode(url.getPath(), "UTF-8")).toURI(); return uri.getPath(); } catch (UnsupportedEncodingException e) { Assertions.UNREACHABLE(); return null; } }  Module getJarFileModule(String fileName); Module getJarFileModule(String fileName, ClassLoader loader); URL getResource(String fileName); URL getResource(String fileName, ClassLoader loader); File getFile(String fileName); File getFile(String fileName, ClassLoader loader); File getFileFromClassLoader(String fileName, ClassLoader loader); InputStream getInputStreamFromClassLoader(String fileName, ClassLoader loader); Module getJarFileFromClassLoader(String fileName, ClassLoader loader); String filePathFromURL(URL url);  }