question: 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 ( ) ; } }
target:  Helper method for storing printed PDF receipts to files