search for jar file in Zip.java instead of trying to load by hard-coded name

This commit is contained in:
Joel Dice 2010-09-20 17:30:39 -06:00
parent 0456a9fd49
commit 88942a9672

View File

@ -1,12 +1,31 @@
import java.io.InputStream;
import java.io.File;
import java.util.Enumeration;
import java.util.zip.ZipFile;
import java.util.zip.ZipEntry;
public class Zip {
private static String findJar(File directory) {
File[] files = directory.listFiles();
for (File file: directory.listFiles()) {
if (file.isFile()) {
if (file.getName().endsWith(".jar")) {
return file.getAbsolutePath();
}
} else if (file.isDirectory()) {
String result = findJar(file);
if (result != null) {
return result;
}
}
}
return null;
}
public static void main(String[] args) throws Exception {
ZipFile file = new ZipFile("build/classpath.jar");
ZipFile file = new ZipFile
(findJar(new File(System.getProperty("user.dir"))));
byte[] buffer = new byte[4096];
for (Enumeration<? extends ZipEntry> e = file.entries();