tags:

views:

231

answers:

1

I have a jar file that has a file named "client.ts" in (when viewing in ZipGenius) "/com/something/messaging". When I do

JarFile jarFile = new JarFile("Client.jar");
JarEntry zipFile = jarFile.getJarEntry("client.ts");

It can't find the "client.ts" file. If I package the file in "/resources/" instead it can find it. Does JarFile.getEntry() only drill down one directory? The javadoc for getJarEntry() simply says: Returns the ZipEntry for the given entry name or null if not found.

+3  A: 

The full path of the entry within the JAR should work:

JarEntry zipFile = jarFile.getJarEntry("com/something/messaging/client.ts");
sblundy
actually the string should be "com/something/messaging/client.ts"
Do you know why it works if it's just in the resources/ directory? Must be java just searches down one directory.
@darrickc.blogspot.com I was fuzzy on that bit. Glad you worked it out.
sblundy
No idea why it works with resources/
sblundy
Zip (and hence jar) files don't actually have a notion of directories. It's just entry names with slashes. You can even have "/../" within names.
Tom Hawtin - tackline