You code will not compile. Class.getResource() returns a URL
, and File
has no constructor with a URL
as an argument.
You can just use .getResourceAsStream()
instead, it returns an InputStream
directly, you just have to read the contents of the file from that stream.
Note: both of these methods return null
if the resource is not found: don't forget to check for that...