From 5434759d20244da2d2188fe2a25da3650e67433c Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 30 Dec 2021 22:31:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E4=B9=A6=E7=B1=8D=E6=97=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=99=E4=BF=9D=E5=AD=98=E5=88=B0=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E9=80=89=E5=AE=9A=E7=9A=84=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/localBook/TextFile.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 935db781a..09caff017 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 @@ -28,7 +28,7 @@ class TextFile(private val book: Book) { fun getChapterList(): ArrayList { return getBookInputStream(book).use { val buffer = ByteArray(BUFFER_SIZE) - it.read(buffer, 0, buffer.size) + it.read(buffer) if (book.charset == null) { book.charset = EncodingDetect.getEncode(buffer) } @@ -54,7 +54,7 @@ class TextFile(private val book: Book) { val buffer = ByteArray(BUFFER_SIZE) val rulePattern = pattern ?: let { bookIs.skip(0) - val length = bookIs.read(buffer, 0, buffer.size) + val length = bookIs.read(buffer) val content = String(buffer, 0, length, charset) tocRule = getTocRule(content) tocRule?.let { @@ -72,7 +72,7 @@ class TextFile(private val book: Book) { var allLength = 0 //获取文件中的数据到buffer,直到没有数据为止 - while (bookIs.read(buffer, 0, BUFFER_SIZE).also { length = it } > 0) { + while (bookIs.read(buffer).also { length = it } > 0) { blockPos++ //如果存在Chapter if (rulePattern != null) { @@ -263,7 +263,7 @@ class TextFile(private val book: Book) { val content = ByteArray(count) getBookInputStream(book).use { it.skip(bookChapter.start!!) - it.read(content, 0, count) + it.read(content) } return String(content, book.fileCharset()) .substringAfter(bookChapter.title)