question: public static void streamContentToBrowser ( HttpServletResponse response , byte [ ] bytes , String contentType , String fileName ) throws IOException { setResponseBrowserProxyNoCache ( response ) ; response . setContentLength ( bytes . length ) ; if ( contentType != null ) { response . setContentType ( contentType ) ; } if ( fileName != null ) { response . setHeader ( "Content-Disposition" , "attachment;filename=" + fileName ) ; } OutputStream out = response . getOutputStream ( ) ; InputStream in = new ByteArrayInputStream ( bytes ) ; try { streamContent ( out , in , bytes . length ) ; } catch ( IOException e ) { in . close ( ) ; out . close ( ) ; throw e ; } in . close ( ) ; out . flush ( ) ; out . close ( ) ; }
target:  Stream an array of bytes to the browser This method will close the ServletOutputStream when finished