From 851a5bcb31eff46629f81de902e935adc60322bd Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 28 Jan 2020 11:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/ZipUtils.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/ZipUtils.kt b/app/src/main/java/io/legado/app/utils/ZipUtils.kt index eab9951c7..44d547e5c 100644 --- a/app/src/main/java/io/legado/app/utils/ZipUtils.kt +++ b/app/src/main/java/io/legado/app/utils/ZipUtils.kt @@ -57,7 +57,7 @@ object ZipUtils { } return true } finally { - if (zos != null) { + zos?.let { zos.finish() zos.close() } @@ -89,7 +89,7 @@ object ZipUtils { } return true } finally { - if (zos != null) { + zos?.let { zos.finish() zos.close() } @@ -261,7 +261,7 @@ object ZipUtils { val files = ArrayList() val zip = ZipFile(zipFile) val entries = zip.entries() - try { + zip.use { if (isSpace(keyword)) { while (entries.hasMoreElements()) { val entry = entries.nextElement() as ZipEntry @@ -285,8 +285,6 @@ object ZipUtils { } } } - } finally { - zip.close() } return files }