UrlUtil { public static URL toURL(String filename) throws MalformedURLException { URL url; try { url = new URL(filename); } catch (MalformedURLException e) { url = new File(filename).toURI().toURL(); } return url; } private  UrlUtil(); static URL toURL(String filename); static URI toNormalizedURI(String filename); static URI toNormalizedURI(File file); static InputStream openStream(URL url); static URL getFinalURL(URL initialUrl); static String getFileUriString(String filename); static String getNormalizedFileUriString(String filename);  }
@Test public void getBaseUriTest() throws IOException { String absolutePathRoot = Paths.get("").toAbsolutePath().toUri().toURL().toExternalForm(); String expected = absolutePathRoot + destinationFolder; File tempFile = FileUtil.createTempFile(destinationFolder); Assert.assertEquals(expected, FileUtil.getParentDirectory(tempFile)); }