I don't think that would work if the resource can't be resolved to a File but is located inside a jar. The only way is to use the InputStream.