try (FileOutputStream fos = new FileOutputStream(out); BufferedOutputStream bos = new BufferedOutputStream(fos)){ JOrphanUtils.write(s.getResponseData(), bos); // chunk the output if necessary } catch (FileNotFoundException e) { log.error("Error creating sample file for {}", s.getSampleLabel(), e);