title: Downloading multiple pdf files using Spring Boot RestController
body: <p>I am trying to use a Spring Boot RestController to download multiple pdf files.But for some reason only the first file is downloaded.The program does not throw any error.Not sure what the issue is.Is Multipart needed for this?</p>
  
  <pre><code>@RequestMapping(value = "downloadAgain", method = RequestMethod.GET)
  @ResponseBody
  public void newRun(HttpServletResponse response) {
  
          String fileName1="pdf1.pdf";
          String fullName1="C://Users//pdf1.pdf";
          newDownloadRun(response,fileName1,fullName1);
  
          String fileName2="pdf2.pdf";
          String fullName2="C://Users//pdf2.pdf";
          newDownloadRun(response,fileName2,fullName2);
      }
  
  
      public void newDownloadRun(HttpServletResponse response,String fileName,String fullName) {
  
          response.setContentType("application/pdf");
          response.setHeader( "Content-Disposition", "attachment;filename="+ fileName );
  
          response.setHeader("Content-disposition", "attachment; filename=" + fileName);
  
          try {
              BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
              FileInputStream fis = new FileInputStream(fullName);
              int len;
              byte[] buf = new byte[1024];
  
              while((len=fis.read(buf))&gt; 0) {
                  bos.write(buf,0,len);
              }
              bos.close();
              response.flushBuffer();
          }catch(Exception ex) {
              ex.printStackTrace();
          }   
      }
  </code></pre>