By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,600 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,600 IT Pros & Developers. It's quick & easy.

Get contents of cached jar

P: n/a
Here is a method that will access the contents of a cached jar if you are
running as an applet.
You can easily adapt it to return a collection or apply a filter on the
filenames to return a
collection of sound files or image files.

public void getJarContents()
// Bootstrap access to the jar contents
// get this class name from the class loader.
URL thisURL = getClass().getResource("xxxxxx.class");

URLConnection connection = thisURL.openConnection();

if (connection instanceof JarURLConnection)
JarFile jar = ((JarURLConnection)connection).getJarFile();
System.out.println("Jar: " + jar);
Enumeration jarEntries = jar.entries();
JarEntry e = (JarEntry) jarEntries.nextElement();
System.out.println("Jar entry: " + e.getName());
catch (Exception e)
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.