I keep my images in a jarfile and load them as followes:
Image image = null;
try
{
image = Toolkit.getDefaultToolkit().getImage( url );
}
catch ( Exception e )
{
// inform user.
}
This works fine, but when i accidently misspell the image name I get:
java.lang.IllegalStateException: zip file closed
at java.util.zip.ZipFile.ensureOpen(Unknown Source)
at java.util.zip.ZipFile.getEntry(Unknown Source)
at java.util.jar.JarFile.getEntry(Unknown Source)
at com.sun.deploy.cache.CachedJarFile.getEntry(Unknow n Source)
at sun.net.
http://www.protocol.jar.JarURLConnec...onnect(Unknown Source)
at sun.plugin.net.protocol.jar.CachedJarURLConnection .connect(Unknown Source)
at sun.plugin.net.protocol.jar.CachedJarURLConnection .getInputStream(Unknown Source)
at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unkno wn Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
Why isn't the exception caught?