//读epub文件
Book book = null;
try {
InputStream inputStr = new FileInputStream(epubPath);
book = epubReader.readEpub(inputStr);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//设置epub文件内title.
//本处修改了toc.ncx文件中的和content.opf中的标签内容.
List titlesList = new ArrayList();
titlesList.add("test book");
book.getMetadata().setTitles(titlesList);
//write epub
EpubWriter epubWriter = new EpubWriter();
try {
OutputStream ouput = new FileOutputStream("mynewbook.epub");
epubWriter.write(book, ouput);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
1