List of usage examples for java.util.zip ZipFile close
public void close() throws IOException
From source file:org.eclipse.epp.internal.logging.aeri.ui.utils.Zips.java
/** * Closes the give zip. Exceptions are printed to System.err. *///from w ww . ja va 2s . com public static boolean closeQuietly(ZipFile z) { if (z == null) { return true; } try { z.close(); return true; } catch (IOException e) { e.printStackTrace(); return false; } }
From source file:com.shazam.fork.TestClassScanner.java
private static void closeZipQuietly(ZipFile zip) { try {//from w w w. ja v a 2 s . c om if (zip != null) { zip.close(); } } catch (IOException e) { } }
From source file:Main.java
public static String getBuildTimestamp(Activity activity) { String s = ""; try {// w ww. j a v a 2 s . c o m ApplicationInfo ai = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), 0); ZipFile zf = new ZipFile(ai.sourceDir); ZipEntry ze = zf.getEntry("classes.dex"); long time = ze.getTime(); s = SimpleDateFormat.getInstance().format(new java.util.Date(time)); zf.close(); } catch (Exception e) { } return s; }
From source file:org.eclipse.recommenders.utils.Zips.java
/** * Closes the give zip. Exceptions are printed to System.err. *//*from w w w . java2 s .c o m*/ public static boolean closeQuietly(ZipFile z) { if (z == null) { return true; } try { z.close(); return true; } catch (IOException e) { System.err.printf("Failed to close zip '%s'. Caught exception printed below.\n", z.getName()); e.printStackTrace(); return false; } }
From source file:edu.umd.cs.buildServer.util.IO.java
public static void closeSilently(ZipFile... args) { for (ZipFile c : args) if (c != null) try { c.close(); } catch (IOException e) { // ignore }/*from w w w .j a v a 2s .co m*/ }
From source file:de.thischwa.pmcms.tool.compression.Zip.java
public static void closeQuietly(final ZipFile zipFile) { try {/*from w ww . jav a 2 s. c o m*/ if (zipFile != null) zipFile.close(); } catch (IOException e) { // ignored } }
From source file:org.cloudfoundry.client.lib.SampleProjects.java
private static File explodeTestApp(File file, TemporaryFolder temporaryFolder) throws IOException { File unpackDir = temporaryFolder.newFolder(file.getName()); if (unpackDir.exists()) { FileUtils.forceDelete(unpackDir); }// w ww. j av a 2 s . com unpackDir.mkdir(); ZipFile zipFile = new ZipFile(file); try { unpackZip(zipFile, unpackDir); } finally { zipFile.close(); } return unpackDir; }
From source file:com.frostwire.util.ZipUtils.java
private static int getItemCount(File file) throws IOException { ZipFile zip = null; int count = 0; try {/*from ww w.j av a2s . c o m*/ zip = new ZipFile(file); count = zip.size(); } finally { try { zip.close(); } catch (Throwable e) { // ignore } } return count; }
From source file:com.openmeap.model.ArchiveFileHelper.java
/** * //ww w . j av a 2 s. c o m * @param archive * @param zipFile * @param events * @return TRUE if the file successfully is exploded, FALSE otherwise. */ public static Boolean unzipFile(ModelManager modelManager, FileOperationManager fileManager, ApplicationArchive archive, File zipFile, List<ProcessingEvent> events) { try { GlobalSettings settings = modelManager.getGlobalSettings(); File dest = archive.getExplodedPath(settings.getTemporaryStoragePath()); if (dest.exists()) { fileManager.delete(dest.getAbsolutePath()); } ZipFile file = null; try { file = new ZipFile(zipFile); fileManager.unzipFile(file, archive.getHash()); } finally { file.close(); } return Boolean.TRUE; } catch (Exception e) { logger.error("An exception occurred unzipping the archive to the viewing location: {}", e); events.add(new MessagesEvent(String.format( "An exception occurred unzipping the archive to the viewing location: %s", e.getMessage()))); } return Boolean.FALSE; }
From source file:org.openoffice.maven.packager.OxtMojoTest.java
private static void checkArchive() throws ZipException, IOException { assertTrue(OXT_FILE + " is not a file", OXT_FILE.isFile()); ZipFile zip = new ZipFile(OXT_FILE); ZipEntry entry = zip.getEntry("META-INF/manifest.xml"); assertNotNull("no manifest inside", entry); zip.close(); }