Example usage for android.util.jar StrictJarFile close

List of usage examples for android.util.jar StrictJarFile close

Introduction

In this page you can find the example usage for android.util.jar StrictJarFile close.

Prototype

public void close() throws IOException 

Source Link

Usage

From source file:android.content.pm.PackageParser.java

public static void closeQuietly(StrictJarFile jarFile) {
    if (jarFile != null) {
        try {// ww  w  .  ja v a  2  s  . co m
            jarFile.close();
        } catch (Exception ignored) {
        }
    }
}

From source file:android.content.pm.PackageParser.java

/**
 * Gathers the {@link ManifestDigest} for {@code pkg} if it exists in the
 * APK. If it successfully scanned the package and found the
 * {@code AndroidManifest.xml}, {@code true} is returned.
 *//* w  w w . j a  v a 2s .c  om*/
public void collectManifestDigest(Package pkg) throws PackageParserException {
    pkg.manifestDigest = null;

    // TODO: extend to gather digest for split APKs
    try {
        final StrictJarFile jarFile = new StrictJarFile(pkg.baseCodePath);
        try {
            final ZipEntry je = jarFile.findEntry(ANDROID_MANIFEST_FILENAME);
            if (je != null) {
                pkg.manifestDigest = ManifestDigest.fromInputStream(jarFile.getInputStream(je));
            }
        } finally {
            jarFile.close();
        }
    } catch (IOException | RuntimeException e) {
        throw new PackageParserException(INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
                "Failed to collect manifest digest");
    }
}