FileInputStream takes the file name as a parameter, not a URL string.
The usual way to get the content that the URL points to is with openStream . You can open the stream to the resource without touching the URL yourself Class / ClassLoader.getResourceAsStream (it opens the URL in the implementation).
Alternatively, you can open the file with:
InputStream in = FileInputStream(new File(url.toURI()));
For a resource, this will require that you have the source class files outside of the jar in your file system. JNLP (Java WebStart) has an API for opening files, this is a safe way.
In general: when converting to String use toString or String.valueOf to understand what you are doing. Also note that String somewhat weakly typed, since the type gives no indication of the format of the data contained in it, so prefer a URI or a File .
source share