本文整理汇总了Java中nl.siegmann.epublib.epub.EpubReader.readEpub方法的典型用法代码示例。如果您正苦于以下问题:Java EpubReader.readEpub方法的具体用法?Java EpubReader.readEpub怎么用?Java EpubReader.readEpub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.siegmann.epublib.epub.EpubReader
的用法示例。
在下文中一共展示了EpubReader.readEpub方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadBook
import nl.siegmann.epublib.epub.EpubReader; //导入方法依赖的package包/类
private void loadBook() {
try {
// 打开书籍
EpubReader reader = new EpubReader();
InputStream is = new FileInputStream(mFilePath);
mBook = reader.readEpub(is);
mTocReferences = (ArrayList<TOCReference>) mBook.getTableOfContents().getTocReferences();
mSpineReferences = mBook.getSpine().getSpineReferences();
setSpineReferenceTitle();
// 解压epub至缓存目录
FileUtils.unzipFile(mFilePath, Constant.PATH_EPUB + "/" + mFileName);
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: epubParse
import nl.siegmann.epublib.epub.EpubReader; //导入方法依赖的package包/类
public String epubParse(InputStream fileIn) throws IOException
{
EpubReader epubReader = new EpubReader();
Book book = epubReader.readEpub(fileIn);
for (int i = 0; i < book.getSpine().size(); i++)
{
InputStream is = book.getSpine().getSpineReferences().get(i).getResource().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
htmltext = sb.toString();
htmltext = htmltext.replaceAll("\\<.*?\\>", "");
}
return htmltext;
}
示例3: getDocumentContent
import nl.siegmann.epublib.epub.EpubReader; //导入方法依赖的package包/类
/**
* Implementation of Public method that is used to return the entire content of a .epub file as a single value String.
* Turns one-by-one all internal html files into String values.
* @return String: the entire content of a .epub file
*/
@Override
public String getDocumentContent() throws IOException {
System.out.println(getUri());
EpubReader epubReader = new EpubReader();
Book book = epubReader.readEpub(new FileInputStream(getUri()));
String entireContent = "";
String textContent = "";
int fileNumber = book.getContents().size();
for(int i=0; i<fileNumber; i++) {
InputStream inputStream = book.getContents().get(i).getInputStream(); // file .html
try {
Scanner scanner = new Scanner(inputStream).useDelimiter("\\A");
entireContent = scanner.hasNext() ? scanner.next() : "";
} finally {
inputStream.close();
}
org.jsoup.nodes.Document doc = Jsoup.parse(entireContent);
textContent += doc.body().text();
textContent += "\n\n";
}
return textContent;
}
示例4: getEbook
import nl.siegmann.epublib.epub.EpubReader; //导入方法依赖的package包/类
/**
* Returns the book of the path
* @return
* @throws IOException
*/
public Book getEbook() throws IOException {
Book ebook;
EpubReader epubReader = new EpubReader();
zipInputStream =
new ZipInputStream(new FileInputStream(path.toFile()), Charset.forName("Cp437"));
ebook = epubReader.readEpub(zipInputStream);
zipInputStream.close();
return ebook;
}