The URL
in
URL resource = getClass().getClassLoader().getResource("/image.jpg");
is a uniform resource locator
. In this case it locates the resource identified by /image.jp
in a .jar
file. Which, as it turns out, is a type of zip
file.
jar:file:/Projects/foobar/target/foobar.app/Contents/Java/foobar-jfx.jar!/image.jpg
A zip entry is not a file, it's just a bunch of bytes that have some meaning to a zip file. If you want to get those bytes as an InputStream
, inflated, you can simply call
InputStream inputStream = resource.openStream();