gpt4 book ai didi

android - 在Android上同时阅读epub文件

转载 作者:行者123 更新时间:2023-11-30 03:08:04 24 4
gpt4 key购买 nike

我在 HTTP 服务器上有一个 epub 文件,当我尝试读取 Ex:作者姓名、书名等时,它会读取整个 epub 文件。我想在阅读整个文件的状态下逐页阅读。注意:here Android epublib 引用。

    @Override
protected String doInBackground(String... params) {
try {
url = new URL(bookPath);
// create the new connection
urlConnection = (HttpURLConnection) url.openConnection();

// set up some things on the connection
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);

// and connect!
urlConnection.connect();
// this will be used in reading the data from the internet
inputStream = urlConnection.getInputStream();

// Load Book from inputStream
book = (new EpubReader()).readEpub(inputStream);
maxLocation = book.getTableOfContents().size();
// get the book's title
String bookName = book.getTitle();
String authorName = book.getMetadata().getAuthors().toString();

Log.i("Books", "Title: " + bookName + " Author: " + authorName);
title = "Title: " + bookName + " Author: " + authorName;

int i = 1;
for (TOCReference index : book.getTableOfContents()
.getTocReferences()) {
stringBuffer.append(index.getTitle() + "</br>");
i++;
}

} catch (Exception e) {
e.printStackTrace();
}
return "Executed";
}

最佳答案

感谢您澄清您使用的是 epublib。

epublib 假定您在本地拥有 EPUB 文件,因此您必须(完全下载!)才能读取其元数据。

如果您正在设计客户端/服务器应用程序,您可能希望仅在服务器端提取和存储元数据,并从客户端访问这些元数据以进行搜索/检索。然后,当您的用户选择她想要的书时,您只将特定的 EPUB 下载到她的设备。

关于android - 在Android上同时阅读epub文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21455655/

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