Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android上并发读取epub文件_Android_Epub - Fatal编程技术网

在Android上并发读取epub文件

在Android上并发读取epub文件,android,epub,Android,Epub,我在HTTP服务器上有一个epub文件,当我尝试读取例如:作者姓名、书名等时,它读取整个epub文件。我想一页一页地读整个文件。 注意:Android epublib参考 @Override protected String doInBackground(String... params) { try { url = new URL(bookPath); // create the new connection

我在HTTP服务器上有一个epub文件,当我尝试读取例如:作者姓名、书名等时,它读取整个epub文件。我想一页一页地读整个文件。 注意: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";
    }
@覆盖
受保护的字符串doInBackground(字符串…参数){
试一试{
url=新url(bookPath);
//创建新连接
urlConnection=(HttpURLConnection)url.openConnection();
//在连接上设置一些东西
urlConnection.setRequestMethod(“GET”);
urlConnection.setDoOutput(true);
//连接!
urlConnection.connect();
//这将用于从互联网读取数据
inputStream=urlConnection.getInputStream();
//从inputStream加载图书
book=(新的EpubReader()).readEpub(inputStream);
maxLocation=book.getTableOfContents().size();
//得到书名
字符串bookName=book.getTitle();
字符串authorName=book.getMetadata().getAuthors().toString();
Log.i(“书籍”、“标题:“+bookName+”作者:“+authorName”);
title=“title:+bookName+”作者:+authorName;
int i=1;
for(参考索引:book.getTableOfContents()
.GetToReferences()){
stringBuffer.append(index.getTitle()+“
”; i++; } }捕获(例外e){ e、 printStackTrace(); } 返回“已执行”; }
感谢您澄清您正在使用epublib

epublib假设您在本地拥有您的EPUB文件,所以您必须(完全!)下载它才能读取其元数据


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

您的代码中的
EpubReader
是什么?它来自哪个图书馆?顺便说一句,EPUB文件是多个文件的(ZIP)容器。在检查元数据之前,您需要下载所有内容。此外,EPUB中没有“页面”的概念。请澄清你的问题。Android epublib参考。如果我无法澄清我的问题,请询问我。