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,7 +20,7 @@ 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);
@ -32,6 +32,7 @@ public class MetaDataReader {
} }
}); });
} }
}
public static byte[] getBytesFromInputStream(InputStream inputStream) throws IOException { public static byte[] getBytesFromInputStream(InputStream inputStream) throws IOException {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {