|
Netscape browsers do not
support the getResource() method, so you must use the getResourceAsStream() method.
Here is an example that extracts an image from a JAR file:
InputStream is;
ByteArrayOutputStream baos;
Image img1;
is = this.getClass().getResourceAsStream("/imagen/ingresos_y_pagos.gif");
if (is == null)
System.out.println("No resource found");
baos = new ByteArrayOutputStream();
try
{
int c;
while((c = is.read()) >= 0)
baos.write(c);
img1 = getToolkit().createImage(baos.toByteArray());
}
catch(IOException e)
{
e.printStackTrace();
}
|