使用epublib逐页读取epub文件
问题描述:
我正在使用epublib逐页读取epub文件并在应用程序中显示的应用程序中,我能够获取书籍章节明智的所有内容,现在我想内容页明智的,PLZ回答,如果你有任何想法,在此先感谢使用epublib逐页读取epub文件
这里是我用于获取本书中的章节内容明智
public String getText(String filepath) {
String linez = "";
File f = new File(filepath);
InputStream epubInputStream = null;
try {
epubInputStream = new FileInputStream(f);
} catch (FileNotFoundException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
Book book = null;
try {
book = (new EpubReader()).readEpub(epubInputStream);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Spine spine = book.getSpine();
List<SpineReference> spineList = spine.getSpineReferences();
int count = spineList.size();
txtpages.setText("Size:" + Integer.toString(count) + "\n");
StringBuilder string = new StringBuilder();
for (int i = 0; count > i; i++) {
Resource res = spine.getResource(i);
try {
InputStream is = res.getInputStream();
BufferedReader reader = new BufferedReader(
new InputStreamReader(is));
try {
while ((line = reader.readLine()) != null) {
linez = string.append(line + "\n").toString();
}
} catch (IOException e) {
e.printStackTrace();
}
// do something with stream
} catch (IOException e) {
e.printStackTrace();
}
}
//webView.loadData(linez, "text/html", "utf-8");
return linez;
}
你需要澄清你的意思是“现在我想明白内容页面”。你的意思是你想分页你的EPUB的的每个XHTML文件吗?如果是这样,您需要注入自己的CSS并将CSS + XHTML加载到WebView中,否则您需要在Java代码中拆分XHTML内容。 –
是的,我想分页每个xhtml –
你是否能够找到答案如何分页。 –