[code]
private void download() throws IOException {
HttpServletResponse response = getResponse();
String fullPath = "e:\\Document\\intra-mart5Demo\\document_list.pdf";
String fileName = fullPath.substring(fullPath.lastIndexOf("\\") + 1);
FileInputStream file = new FileInputStream(fullPath);
//set response
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
//print
ServletOutputStream out = response.getOutputStream();
out.flush();
byte buffer[] = new byte[1024];
int size;
while ((size = file.read(buffer)) != -1) {
out.write(buffer, 0, size);
out.flush();
}
file.close();
out.close();
}[/code]
private void download() throws IOException {
HttpServletResponse response = getResponse();
String fullPath = "e:\\Document\\intra-mart5Demo\\document_list.pdf";
String fileName = fullPath.substring(fullPath.lastIndexOf("\\") + 1);
FileInputStream file = new FileInputStream(fullPath);
//set response
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
ServletOutputStream out = response.getOutputStream();
out.flush();
byte buffer[] = new byte[1024];
int size;
while ((size = file.read(buffer)) != -1) {
out.write(buffer, 0, size);
out.flush();
}
file.close();
out.close();
}[/code]