我在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";
}
答案 0 :(得分:1)
感谢您澄清您正在使用epublib。
epublib假设您在本地拥有EPUB文件,因此您必须先下载它(完全!)才能阅读其元数据。
如果您正在设计客户端/服务器应用程序,您可能希望仅在服务器端提取和存储元数据,并从客户端访问这些元数据以进行搜索/检索。然后,当您的用户选择她想要的书时,您只能将该设备下载到她的设备。