title: How can i download the PDF file in spring mvc?
body: <p>this is my file path</p>
  
  <pre><code>public final static String BOOKINGPDFFILE= "D:/Hotels/pdf/";
  </code></pre>
  
  <p>This below code is what  I have written to download pdf from the above resource folder</p>
  
  <pre><code>Pdf="column name in database  i used for storing in database"
  
  @RequestMapping(value = "/getpdf/{pdf}", method = RequestMethod.GET)
  public  void getPdf(@PathVariable("pdf") String fileName, HttpServletResponse response,HttpServletRequest request) throws IOException {
  
  
     try {
          File file = new File(FileConstant.BOOKINGPDFFILE + fileName+ ".pdf");
  
  
          Files.copy(file.toPath(),response.getOutputStream());
      } catch (IOException ex) {
          System.out.println("Contract Not Found");
          System.out.println(ex.getMessage());
      }
  
  }
  </code></pre>