title: ServletOutputStream byte array to pdf corrupt pdf
body: <p>I use tomcat 7.0.53, Struts 1.2.7, Spring 3.1.1. This is my code:</p>
  
  <pre><code>File file = new File("C:\\pdf\\" + report.getFileName());
  FileOutputStream fos = new FileOutputStream(file);
  fos.write(report.getData());
  fos.close();
  
  response.addHeader("Content-disposition", "application; filename="
                      + report.getFileName());
  response.setContentType("application/pdf");
  response.setContentLength(report.getData().length);
  
  ServletOutputStream outputStream = response.getOutputStream();
  outputStream.write(report.getData());
  outputStream.flush();
  </code></pre>
  
  <p>The file I get is right no problem there. But the file I get from response is corrupted. I tried to set encoding to response, tried to turn on spring CharacterEncodingFilter, tomcats SetCharacterEncodingFilter. Nothing helps. Where should I look at?
  p.s. this code is in Struts Action execute method</p>