gpt4 book ai didi

android - 如何从epub文件中阅读整章?

转载 作者:行者123 更新时间:2023-11-29 22:16:08 24 4
gpt4 key购买 nike

我想制作 epub 阅读器 应用程序。现在我只得到文件中的章节名称,但如何获取章节中的全部数据。

最佳答案

我想我之前已经发布过这个了。使用你可以谷歌搜索的 nl.siegmann.epublib。在我的代码中,当您查看 Book 类时,我将向您展示我是如何做到的,该类展示了 epub 是如何工作的。在书籍类上使用 Spine 我得到了书的最大书脊,这意味着整本书。然后我将它转换为字符串。

这是我的代码,说明我是如何做到的。

public String getEntireBook()
{
String line, linez = null;
Spine spine = amBook().getSpine();
Resource res;
List<SpineReference> spineList = spine.getSpineReferences() ;

int count = spineList.size();
int start = 0;

StringBuilder string = new StringBuilder();
for (int i = start; count > i; i = i +1) {
res = spine.getResource(i);

try {
InputStream is = res.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
while ((line = reader.readLine()) != null) {
linez = string.append(line + "\n").toString();
}

} catch (IOException e) {e.printStackTrace();}
} catch (IOException e) {
e.printStackTrace();
}
}
return linez;
}

关于android - 如何从epub文件中阅读整章?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8428724/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com