Code example for ByteArrayOutputStream

Methods: close, flush, toByteArray

0
    band.addElement(e);
  } 
 
  public byte[] generate(final MasterReport report) throws ReportProcessingException, IOException
  { 
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    final StreamRepository targetRepository = new StreamRepository(null, outputStream, "report"); //$NON-NLS-1$
    final ContentLocation targetRoot = targetRepository.getRoot();
 
    final PageableHtmlOutputProcessor outputProcessor = new PageableHtmlOutputProcessor(report.getConfiguration());
    final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
    printer.setContentWriter(targetRoot, new DefaultNameGenerator(targetRoot, "index", "html"));//$NON-NLS-1$//$NON-NLS-2$
    outputProcessor.setPrinter(printer);
 
    outputProcessor.setFlowSelector(new ReportPageSelector(0));
    final PageableReportProcessor proc = new PageableReportProcessor(report, outputProcessor);
    proc.processReport();
    proc.close();
 
    outputStream.flush();
    outputStream.close();
    return outputStream.toByteArray();
  } 
}