How to set default path for store PDF

Gnanaseelan :

I have to store this pdf file in my "/home/gnanaseelan/Documents/myfile" this location How is?

ByteArrayInputStream bis = PDFGenerator.customerPDFReport(myLayout);

  HttpHeaders headers = new HttpHeaders();
  headers.add("Content-Disposition", "attachment;filename=mypdf.pdf");
       return ResponseEntity
                .ok()
                .headers(headers)
                .contentType(MediaType.APPLICATION_PDF)
                .body(new InputStreamResource(bis));
N. Helldorff :

If you have IOUtils (Apache Commons io) you can do it with

IOUtils.copy(byteArrayInputStream, new FileOutputStream("/home/gnanaseelan/Documents/myfile.pdf"));

https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=152870&siteId=1