From 251e09e53f8d406ec7ff5e9db03181724c6e5221 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 23 Feb 2022 19:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtxt=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/localBook/TextFile.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt index 300ee982c..04625c2a5 100644 --- a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt @@ -60,18 +60,13 @@ class TextFile(private val book: Book) { if (book.charset == null || book.tocUrl.isBlank()) { LocalBook.getBookInputStream(book).use { bis -> val buffer = ByteArray(bufferSize) - var blockContent: String - var length = bis.read(buffer) + val length = bis.read(buffer) if (book.charset.isNullOrBlank()) { book.charset = EncodingDetect.getEncode(buffer.copyOf(length)) } charset = book.fileCharset() - blockContent = String(buffer, 0, length, charset) if (book.tocUrl.isBlank()) { - if (blockContent.isEmpty()) { - length = bis.read(buffer) - blockContent = String(buffer, 0, length, charset) - } + val blockContent = String(buffer, 0, length, charset) book.tocUrl = getTocRule(blockContent)?.pattern() ?: "" } }