2014-01-30 104 views
1

我在HTTP服务器上有一个epub文件,当我尝试读取Ex:Author Name,Book Title等时,它读取了整个epub文件。我想阅读整个文件的阅读页面。 NB:here Android epublib参考。同时阅读Android上的epub文件

@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

什么是你的代码中的'EpubReader'?它来自哪个图书馆? 顺便说一句,EPUB文件是几个文件的(ZIP)容器。在检查元数据之前,您需要先下载它。 此外,在EPUB中没有“页面”的概念。 请澄清你的问题。 –

+0

[这里](http://www.siegmann.nl/epublib/android)Android epublib参考。 –

+0

请问我是否无法澄清我的问题。 –

回答

1

感谢您澄清您使用epublib。

epublib假定你有本地EPUB文件,所以你必须下载它(完全!),然后才能读取其元数据。

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