int length = 0; if (reader != null) { char[] buffer = new char[512]; PrintWriter out = response.getWriter();  while ( (length = this.reader.read(buffer)) != -1 ) { out.write(buffer, 0, length); } this.reader.close(); } else { byte[] buffer = new byte[512]; ServletOutputStream out = response.getOutputStream();  while ( (length = this.inputStream.read(buffer)) != -1) { out.write(buffer, 0, length); }  this.inputStream.close(); }
stream(response);
    public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {        response.setContentType(this.contentType);        if (this.characterEncoding != null) response.setCharacterEncoding(characterEncoding);        // If a filename was specified, set the appropriate header        if (this.filename != null) {            response.setHeader("Content-disposition", "attachment; filename=" + this.filename);        }        int length = 0;        if (reader != null) {            char[] buffer = new char[512];            PrintWriter out = response.getWriter();            while ( (length = this.reader.read(buffer)) != -1 ) {                out.write(buffer, 0, length);            }            this.reader.close();        }        else {            byte[] buffer = new byte[512];            ServletOutputStream out = response.getOutputStream();            while ( (length = this.inputStream.read(buffer)) != -1) {                out.write(buffer, 0, length);            }            this.inputStream.close();        }    }