Close JarFile

This commit is contained in:
kotori0 2020-12-21 15:56:35 +08:00
parent 7451fbbeda
commit 25dc7c0bc8
No known key found for this signature in database
GPG Key ID: 3FEE57ED0385A6B2
1 changed files with 12 additions and 11 deletions

View File

@ -20,17 +20,18 @@ public class MetaDataReader {
}
private MetaDataReader(File apk) throws IOException {
JarFile zip = new JarFile(apk);
InputStream is = zip.getInputStream(zip.getEntry("AndroidManifest.xml"));
byte[] bytes = getBytesFromInputStream(is);
AxmlReader reader = new AxmlReader(bytes);
reader.accept(new AxmlVisitor() {
@Override
public NodeVisitor child(String ns, String name) {
NodeVisitor child = super.child(ns, name);
return new ManifestTagVisitor(child);
}
});
try(JarFile zip = new JarFile(apk)) {
InputStream is = zip.getInputStream(zip.getEntry("AndroidManifest.xml"));
byte[] bytes = getBytesFromInputStream(is);
AxmlReader reader = new AxmlReader(bytes);
reader.accept(new AxmlVisitor() {
@Override
public NodeVisitor child(String ns, String name) {
NodeVisitor child = super.child(ns, name);
return new ManifestTagVisitor(child);
}
});
}
}
public static byte[] getBytesFromInputStream(InputStream inputStream) throws IOException {