Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public byte[] readPDF() {
- File output = new File("C:\\Workspace\\Ksenija.pdf");
- Path pdfPath = null;
- byte[] pdf = null;
- if(output.exists()){
- pdfPath = Paths.get("C:\\Workspace\\Ksenija.pdf");
- }
- else {System.out.print("nema podataka");}
- try {
- pdf = Files.readAllBytes(pdfPath);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return pdf;
- }
- @Override
- public byte[] getPDF() {
- try {
- return this.jdbcTemplate.queryForObject("SELECT GENERIRANI_DOKUMENT FROM INS_RAZNO.CARGOPRIJAVA WHERE ID = 1", byte[].class);
- }
- catch(DataAccessException ex) {
- ex.printStackTrace();
- return null;
- }
- }
- //////////////////////////////////////////////controler
- @RequestMapping(value = "/download")
- public void writer() throws IOException {
- byte[] pdf = kDAO.getPDF();
- try(FileOutputStream fos = new FileOutputStream("C:\\Users\\y095722\\Desktop\\test.pdf")){
- fos.write(pdf);
- }
- catch(IOException ex) {
- ex.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment