I want to open files using the class loader. However I always get a FileNotFoundException. How do I create a new File using the URL? I don’t want to open it as a stream just as a file.
URL url = VersionUpdater.class.getResource("xslt/screen/foo");
File f = ...
To convert a
file://...URL tojava.io.File, you’ll have to combine bothurl.getPath()andurl.toURI()for a safe solution:Full explanations in this blog post.