SimplePathBuilder implements PathBuilder { @Override public URL getCurrentDirectoryURL() { try { if (this.currentFile != null) { return this.currentFile.toURI().toURL(); } if (this.currentURL != null) { return this.currentURL; } try { return FileSystem.getUserHomeDirectory().toURI().toURL(); } catch (IOException exception) { return new File((String) null).toURI().toURL(); } } catch (MalformedURLException exception) { return null; } } SimplePathBuilder();  SimplePathBuilder(String currentDirectory);  SimplePathBuilder(File currentDirectory);  SimplePathBuilder(URL currentDirectory); @Override void setCurrentDirectory(String currentDirectory); @Override void setCurrentDirectory(File currentDirectory); @Override void setCurrentDirectory(URL currentDirectory); @Override File getCurrentDirectoryFile(); @Override URL getCurrentDirectoryURL();  }
@Test public void testGetCurrentDirectoryURL() throws Exception { assertEquals(this.userHome.toURI().toURL(), this.builder.getCurrentDirectoryURL()); this.builder.setCurrentDirectory("file:./toto"); assertEquals(new URL("file:./toto"), this.builder.getCurrentDirectoryURL()); this.builder.setCurrentDirectory("http: assertEquals(new URL("http: this.builder.setCurrentDirectory("https: assertEquals(new URL("https: this.builder.setCurrentDirectory("ftp: assertEquals(new URL("ftp: this.builder.setCurrentDirectory("jar:file:test.jar!/toto"); assertEquals(new URL("jar:file:test.jar!/toto"), this.builder.getCurrentDirectoryURL()); this.builder.setCurrentDirectory("./toto"); assertEquals(new File("./toto").toURI().toURL(), this.builder.getCurrentDirectoryURL()); }