String (String uri) { // hmm, this code sucks, but seems to be a good guess to ensure the same format of // strings (file:/C:/... vs, file:///C:/...) on both sides... try { try { uri = uri.replaceAll(" ", "%20"); return new File(new URI(uri)).toURI().toASCIIString(); } catch (IllegalArgumentException e) { return new URI(uri).normalize().toASCIIString(); } } catch (URISyntaxException e) { System.err.println("Failed to parse <" + uri + ">: " + e); return uri; } }