post your comment   print   send to a friend
Rate:   0% | Views: 500
Question categories:  Java

How can I extract resources from a JAR file loaded over the Internet?

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();
}

Customer Feedback
Rate:   0% | Views: 500 | Please Rate:  
 
If you have other comments or ideas for future technical tips, please type them here:

Email: (optional)

Comments: (optional)

 Custom Web Design | Web Hosting Company    Back to serch results
Browse the Base
Knowledge Base
Web Design
  Do It Yourself
    Java
Messages
 

$75 Free Google AdWords

Free $75 Google AdWords when you sign up for WebImage! Target by location, create your own, or let Google create your ads for you. Check out http://www.aplus.net/google.html to see how AdWords works for you.

Private Area
 
Ask
in Private
   
Personal
Folder
 
Related Questions
 
1. How do I access Servlets or CGI programs from Java?
 
2. My applet computes its window size. Can I resize it in the browser?
 
3. How do I communicate between my applets in the same browser?
 
4. How do I force the browser to reload my Java classes without exiting Navigator?
 
5. Why does my java console show an applet is pruned?
 
Home Browse Search Ask in Private Personal Folder   Help
powered by web hosting 
  Logged as: Guest