@@ -0,0 +1,1509 @@
+package gov.nih.nci.calab.service.util;%0A%0Aimport java.io.BufferedInputStream;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0A%0Aimport javax.servlet.ServletOutputStream;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Apublic class ActionUtil%0A%7B%0A    public void writeBinaryStream(File file, HttpServletResponse response) throws Exception%0A    %7B%0A        if (file == null %7C%7C response == null)%0A        %7B%0A            throw new Exception(%22Unable to write file to HttpServletResponse: %22 +%0A                %22Either pathName or response is null.%22);%0A        %7D%0A        try%0A        %7B%0A            // set a non-standard content type to force brower to open Save As dialog%0A            response.setContentType(%22application/octet-stream%22);%0A            response.setHeader(%22Content-Disposition%22, %22attachment; filename=%22 + file.getName());%0A            ServletOutputStream sos = response.getOutputStream();%0A            BufferedInputStream bis =  new BufferedInputStream(new FileInputStream(file));%0A            byte%5B%5D buf = new byte%5B1024 * 10%5D; // ~= 10KB%0A            for (int len = -1; (len = bis.read(buf)) != -1; )%0A            %7B%0A                sos.write(buf, 0, len);%0A            %7D%0A            response.setContentLength((int)file.length());%0A            sos.flush(); // let the Servlet container handle closing of this ServletOutputStream%0A            bis.close();%0A        %7D%0A        catch (Exception e)%0A        %7B%0A            throw new Exception(%22Unable to write file to client, exception is %22 + e.toString());%0A        %7D%0A%0A    %7D%0A%7D%0A

Write binary stream to the client for download file