Source:
<code>public Response getBuildArchive(@PathParam("programId") String programId, @PathParam("buildId") final String buildId, @DefaultValue("UNKNOWN") @QueryParam("program") final String programName, @DefaultValue("UNKNOWN") @QueryParam("build") final String buildName) { final String fileName = programName + "_" + buildName; ContentDisposition contentDisposition = ContentDisposition.type("attachment").fileName(fileName + ".zip").creationDate(new Date()).build(); return Response.ok(new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { ByteArrayOutputStream tableStream = new ByteArrayOutputStream(); final ZipOutputStream zout = new ZipOutputStream(output); final String serverData = OseeServerProperties.getOseeApplicationServerData(null); PcrIdCollector collector = new PcrIdCollector() { @Override public void onPcrId(String pcrId) { String pcrFileName = pcrId + ".xml"; File file = new File(serverData + CHANGE_REPORTS_PATH + pcrFileName); if (file.exists()) { try { zout.putNextEntry(new ZipEntry("changeReports/" + pcrFileName)); <START> zout.write(Lib.fileToBytes(file)); <END> zout.closeEntry(); } catch (IOException ex) { OseeExceptions.wrapAndThrow(ex); } } } }; createTraceReport(buildId, programName, buildName, AtsElementData.ARCHIVE_URL_TEMPLATE, collector, tableStream); zout.putNextEntry(new ZipEntry(fileName + ".html")); tableStream.writeTo(zout); zout.closeEntry(); zout.close(); } }).header("Content-Disposition", contentDisposition).build(); }</code><technical_language>call Lib.fileToBytes read entire file memory. A memory intesive of this FileInputStream read file call Lib.inputStreamToOutputStream transfer in a buffered manner data streams</technical_language>

Target:
public Response getBuildArchive(@PathParam("programId") String programId, @PathParam("buildId") final String buildId, @DefaultValue("UNKNOWN") @QueryParam("program") final String programName, @DefaultValue("UNKNOWN") @QueryParam("build") final String buildName) { final String fileName = programName + "_" + buildName; ContentDisposition contentDisposition = ContentDisposition.type("attachment").fileName(fileName + ".zip").creationDate(new Date()).build(); return Response.ok(new StreamingOutput() { @Override public void write(OutputStream output) throws WebApplicationException { ByteArrayOutputStream tableStream = new ByteArrayOutputStream(); final ZipOutputStream zout = new ZipOutputStream(output); final String serverData = OseeServerProperties.getOseeApplicationServerData(null); Set<String> pcrIds = new HashSet<String>(); createTraceReport(buildId, programName, buildName, AtsElementData.ARCHIVE_URL_TEMPLATE, pcrIds, tableStream); try { zout.putNextEntry(new ZipEntry(fileName + ".html")); tableStream.writeTo(zout); zout.closeEntry(); for (String pcrId : pcrIds) { String pcrFileName = pcrId + ".xml"; File file = new File(serverData + CHANGE_REPORTS_PATH + pcrFileName); if (file.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(file); zout.putNextEntry(new ZipEntry("changeReports/" + pcrFileName)); Lib.inputStreamToOutputStream(fis, zout); zout.closeEntry(); } catch (IOException ex) { OseeExceptions.wrapAndThrow(ex); } finally { Lib.close(fis); } } } } catch (IOException ex) { OseeExceptions.wrapAndThrow(ex); } finally { Lib.close(zout); } } }).header("Content-Disposition", contentDisposition).build(); }