To convert the file://... URL to java.io.File , you need to combine both url.getPath() and url.toURI() for a safe solution:
File f; try { f = new File(url.toURI()); } catch(URISyntaxException e) { f = new File(url.getPath()); }
Full explanation in this post.
source share