Example #1
0
 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;
 }
Example #2
0
 @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;
 }