Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Files.exists(file)) {
- response.setContentType(existingDocuments.getContentType());
- response.addHeader("Content-Disposition", "attachment; filename=" + existingDocuments.getFileName());
- Files.copy(file, response.getOutputStream());
- response.getOutputStream().flush();
- }
- String filePath=request.getParameter("filepath");
- File file=new File(filePath);
- response.setContentType("application/octet-stream");
- response.setHeader("Content-Disposition",
- "attachment;filename="+file.getName());
- InputStream is=new FileInputStream(file);
- int read=0;
- byte[] bytes = new byte[256];
- OutputStream os = response.getOutputStream();
- while((read = is.read(bytes))!= -1){
- os.write(bytes, 0, read);
- }
- os.flush();
- is.close();
- os.close();
- response.header("content-disposition", "attachment; filename="" + fileNameDisplay + """);
Add Comment
Please, Sign In to add comment