From 88942a96728566a0bd0d6a05ca7b0ba342cd4a5b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Sep 2010 17:30:39 -0600 Subject: [PATCH] search for jar file in Zip.java instead of trying to load by hard-coded name --- test/Zip.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/Zip.java b/test/Zip.java index 2aea1760f1..665086ea68 100644 --- a/test/Zip.java +++ b/test/Zip.java @@ -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 e = file.entries();