From 6a3b93ef8ae5a055420aa916472b6bdc206d1fef Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 16 Aug 2019 14:40:24 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/help/BookHelp.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 965096352..69c95140d 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -8,6 +8,7 @@ import java.io.BufferedWriter import java.io.File import java.io.FileWriter import java.io.IOException +import java.nio.charset.StandardCharsets object BookHelp { @@ -34,14 +35,24 @@ object BookHelp { } fun hasContent(book: Book, bookChapter: BookChapter): Boolean { - - + val filePath = getChapterPath(book, bookChapter) + runCatching { + val file = File(filePath) + if (file.exists()) { + return true + } + } return false } fun getContent(book: Book, bookChapter: BookChapter): String? { - - + val filePath = getChapterPath(book, bookChapter) + runCatching { + val file = File(filePath) + if (file.exists()) { + return String(file.readBytes(), StandardCharsets.UTF_8) + } + } return null }