mirror of
https://github.com/revanced/multidexlib2.git
synced 2025-04-29 22:24:28 +02:00
Use try-with-resources
This commit is contained in:
parent
f59046497d
commit
36a2aa8c1a
@ -38,11 +38,8 @@ public class RawDexIO {
|
||||
|
||||
public static DexBackedDexFile readRawDexFile(File file, Opcodes opcodes) throws IOException {
|
||||
/*
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
try {
|
||||
try (InputStream inputStream = new FileInputStream(file)) {
|
||||
return readRawDexFile(inputStream, file.length(), opcodes);
|
||||
} finally {
|
||||
inputStream.close();
|
||||
}
|
||||
*/
|
||||
byte[] buf = Files.toByteArray(file);
|
||||
|
@ -37,27 +37,21 @@ public class ZipFileDexContainer extends AbstractMultiDexContainer<WrappingMulti
|
||||
|
||||
public ZipFileDexContainer(File zip, DexFileNamer namer, Opcodes opcodes) throws IOException {
|
||||
Map<String, WrappingMultiDexFile<DexBackedDexFile>> entryMap = new TreeMap<>(new DexFileNameComparator(namer));
|
||||
ZipFile zipFile = new ZipFile(zip);
|
||||
try {
|
||||
try (ZipFile zipFile = new ZipFile(zip)) {
|
||||
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
|
||||
while (zipEntries.hasMoreElements()) {
|
||||
ZipEntry zipEntry = zipEntries.nextElement();
|
||||
String entryName = zipEntry.getName();
|
||||
if (namer.isValidName(entryName)) {
|
||||
DexBackedDexFile dexFile;
|
||||
InputStream inputStream = zipFile.getInputStream(zipEntry);
|
||||
try {
|
||||
try (InputStream inputStream = zipFile.getInputStream(zipEntry)) {
|
||||
dexFile = RawDexIO.readRawDexFile(inputStream, zipEntry.getSize(), opcodes);
|
||||
} finally {
|
||||
inputStream.close();
|
||||
}
|
||||
WrappingMultiDexFile<DexBackedDexFile> multiDexFile =
|
||||
new BasicMultiDexFile<>(this, entryName, dexFile);
|
||||
if (entryMap.put(entryName, multiDexFile) != null) throwDuplicateEntryName(entryName);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
zipFile.close();
|
||||
}
|
||||
initialize(entryMap, opcodes);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user