- Catch unzip fd leaks on error
      - Move 2 test classes out of the lib
This commit is contained in:
zzz
2009-07-31 17:55:38 +00:00
parent 0bef85277e
commit 1cba7b8ec1
3 changed files with 7 additions and 3 deletions

View File

@ -76,9 +76,10 @@ public class FileUtil {
}
public static boolean extractZip(File zipfile, File targetDir) {
ZipFile zip = null;
try {
byte buf[] = new byte[16*1024];
ZipFile zip = new ZipFile(zipfile);
zip = new ZipFile(zipfile);
Enumeration entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
@ -124,12 +125,15 @@ public class FileUtil {
}
}
}
zip.close();
return true;
} catch (IOException ioe) {
System.err.println("ERROR: Unable to extract the zip file");
ioe.printStackTrace();
return false;
} finally {
if (zip != null) {
try { zip.close(); } catch (IOException ioe) {}
}
}
}