Close JarFile
This commit is contained in:
parent
7451fbbeda
commit
25dc7c0bc8
|
|
@ -20,17 +20,18 @@ public class MetaDataReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private MetaDataReader(File apk) throws IOException {
|
private MetaDataReader(File apk) throws IOException {
|
||||||
JarFile zip = new JarFile(apk);
|
try(JarFile zip = new JarFile(apk)) {
|
||||||
InputStream is = zip.getInputStream(zip.getEntry("AndroidManifest.xml"));
|
InputStream is = zip.getInputStream(zip.getEntry("AndroidManifest.xml"));
|
||||||
byte[] bytes = getBytesFromInputStream(is);
|
byte[] bytes = getBytesFromInputStream(is);
|
||||||
AxmlReader reader = new AxmlReader(bytes);
|
AxmlReader reader = new AxmlReader(bytes);
|
||||||
reader.accept(new AxmlVisitor() {
|
reader.accept(new AxmlVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public NodeVisitor child(String ns, String name) {
|
public NodeVisitor child(String ns, String name) {
|
||||||
NodeVisitor child = super.child(ns, name);
|
NodeVisitor child = super.child(ns, name);
|
||||||
return new ManifestTagVisitor(child);
|
return new ManifestTagVisitor(child);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getBytesFromInputStream(InputStream inputStream) throws IOException {
|
public static byte[] getBytesFromInputStream(InputStream inputStream) throws IOException {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue