Get contents of cached jar
From: Robert Sullivan (r_sulliv_at_bellsouth.net)
Date: 03/29/04
- Previous message: Jonathan Turkanis: "Re: @@@ TEMPTATION KINDLED MY FAITH @@@"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Mar 2004 19:17:38 -0500
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()
{
try
{
// Bootstrap access to the jar contents
// get this class name from the class loader.
URL thisURL = getClass().getResource("xxxxxx.class");
System.out.println(thisURL);
URLConnection connection = thisURL.openConnection();
System.out.println(connection);
if (connection instanceof JarURLConnection)
{
JarFile jar = ((JarURLConnection)connection).getJarFile();
System.out.println("Jar: " + jar);
Enumeration jarEntries = jar.entries();
while(jarEntries.hasMoreElements())
{
JarEntry e = (JarEntry) jarEntries.nextElement();
System.out.println("Jar entry: " + e.getName());
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
- Previous message: Jonathan Turkanis: "Re: @@@ TEMPTATION KINDLED MY FAITH @@@"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]