URLUtil { public static File urlToFile(URL url) { if (!URLUtil.isFileUrl(url)) { return null; } try { return new File(url.toURI()); } catch (Exception e1) { try { return new File(url.getPath()); } catch (Exception e2) { } } return null; }  static boolean isHttpsUrl(URL url); static boolean isHttpUrl(URL url); static boolean isFileUrl(URL url); static boolean isForResourceWithExtension(URL url, String extension); static URL stripQuery(URL url); static File urlToFile(URL url); static URL fromString(String urlString); static URL fromString(String urlString, String protocol); static URL fromObject(Object source); static URI toURI(URL url); static String addQueryParameter(String urlString, String queryParameter); static String addQueryParameterIfMissing(String urlString, String queryParameter, boolean ignoreCase); static boolean hasQueryParameter(String urlString, String queryParameter, boolean ignoreCase);  }
@Test public void testUrlToFileWithNull() { File result = URLUtil.urlToFile(null); assertEquals(null, result); }
@Test public void testUrlToFileWithFileUrl() throws Exception { File result = URLUtil.urlToFile(new URL("file: assertEquals("C:\\this\\is\\a\\file.extension", result.getAbsolutePath()); }
@Test public void testUrlToFileWithHttpUrl() throws Exception { File result = URLUtil.urlToFile(new URL("http: assertEquals(null, result); }