title: HttpServletResponse PrintWriter to write an InputStream
body: <p>I have a HttpServletResponse object and need to write a file contained in the jar. The following code segments do not work for me. </p>
  
  <pre><code>URI uri = &lt;myclass&gt;.class.getResource("/" + filename).toURI(); 
  PrintWriter out = response.getWriter();
  File f = new File(uri); 
  FileReader bis = new FileReader(f);
  char[] buff = new char[1024];
  int bytesRead;
  // Simple read/write loop.
  while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
      out.write(buff, 0, bytesRead);
  }
  </code></pre>
  
  <p>I know that this will work</p>
  
  <pre><code>InputStream inputStream = &lt;myclass&gt;.class.getResourceAsStream("/" + filename);
  </code></pre>
  
  <p>but I cannot get the PrintWriter out.write to write the inputStream.</p>
  
  <p>Can anyone tell me how this can be done. </p>
  
  <p>Thanks</p>