public static void writeReceiptsToFiles(List<byte[]> printedReceipts,String prefix,File baseDir){
  try {
    int index=1;
    for (    byte[] printedReceipt : printedReceipts) {
      ByteArrayInputStream bIn=new ByteArrayInputStream(printedReceipt);
      File receiptFile=new File(baseDir,prefix + "Receipt " + index+ ".pdf");
      BufferedOutputStream bufferedOutputStream=new BufferedOutputStream(new FileOutputStream(receiptFile));
      IOUtils.copy(bIn,bufferedOutputStream);
      bufferedOutputStream.close();
      index++;
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

public static void writeReceiptsToFiles ( List < byte [ ] > printedReceipts , String prefix , File baseDir ) { try { int index = 1 ; for ( byte [ ] printedReceipt : printedReceipts ) { ByteArrayInputStream bIn = new ByteArrayInputStream ( printedReceipt ) ; File receiptFile = new File ( baseDir , prefix + "Receipt " + index + ".pdf" ) ; BufferedOutputStream bufferedOutputStream = new BufferedOutputStream ( new FileOutputStream ( receiptFile ) ) ; IOUtils . copy ( bIn , bufferedOutputStream ) ; bufferedOutputStream . close ( ) ; index ++ ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
helper method for storing printed pdf receipts to files
