1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Runtime runtime = Runtime.getRuntime();
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename= \"" + path+resultat + "\"");
ServletOutputStream out3 = response.getOutputStream();
File file = new File(path+resultat);
response.setContentLength((int) file.length());
int bufferSize = 64 * 1024;
long time = System.currentTimeMillis();
BufferedInputStream from = new BufferedInputStream(new FileInputStream(file), bufferSize * 2);
byte[] bufferFile = new byte[bufferSize];
for (int m = 0; ; m++) {
int len = from.read(bufferFile);
if (len < 0) break;
out3.write(bufferFile, 0, len);
out3.flush(); f=1;}
from.close();
out3.close(); |
Partager