How do I read an Image from a JAR file with Netscape browsers?

John Zukowski

The Communicator 4.x browsers do not implement the Class.getResource(), ClassLoader.getResource(), and ClassLoader.getSystemResource() methods. You need to use the Class.getResourceAsStream(), ClassLoader.getResourceAsStream(), or ClassLoader.getSystemResourceAsStream() methods instead, respectively. See http://developer.netscape.com/docs/technote/java/getresource/getresource.html for more information.

With that said, the following will load an Image:

InputStream in = getClass().getResourceAsStream("image.gif"); 
byte buffer[] = new byte[in.available()]; 
Image image = Toolkit.getDefaultToolkit().createImage(buffer); 
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.