protected InputStream getInputStream() throws Exception { if (data != null) { return FileUtils.createInputStream(data); } if (inputStream != null) { data = FileUtils.createByteArray(inputStream, true); return FileUtils.createInputStream(data); } if (inputFile != null) { inputStream = new BufferedInputStream(new FileInputStream(inputFile)); data = FileUtils.createByteArray(inputStream, true); return FileUtils.createInputStream(data); } return inputStream; }
@Override public Book readBook() throws Exception { if (book == null) { if (data == null) { data = FileUtils.createByteArray(getInputStream(), true); } book = new Book(); book.setTitle(bookTitle); book = this.parseBookFromXml(book, getInputStream()); } return book; }
public HtmlBookReader(File file) { this.bookTitle = FileUtils.getFileNameWithoutExt(file); this.inputFile = file; }