|
@@ -184,24 +184,29 @@ public class DailyReportController extends BaseController {
|
|
|
response.setHeader("Content-type",type);
|
|
|
String filename = new String(descFile.getName().getBytes("utf-8"), "iso-8859-1");
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
|
|
|
- //输出pdf流
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.reset();
|
|
|
OutputStream outputStream1 = response.getOutputStream();
|
|
|
- byte[] buff = new byte[1024];
|
|
|
BufferedInputStream bis = null;
|
|
|
bis = new BufferedInputStream(new FileInputStream(descFile));
|
|
|
- int i = bis.read(buff);
|
|
|
- while (i != -1) {
|
|
|
- outputStream1.write(buff, 0, buff.length);
|
|
|
- outputStream1.flush();
|
|
|
- i = bis.read(buff);
|
|
|
- }
|
|
|
+ byte[] buff = new byte[bis.available()];
|
|
|
+ bis.read(buff);
|
|
|
+ outputStream1.write(buff);
|
|
|
outputStream1.close();
|
|
|
bis.close();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}finally {
|
|
|
- if(descFile!=null)
|
|
|
- descFile.deleteOnExit();
|
|
|
+// if(descFile!=null)
|
|
|
+// descFile.deleteOnExit();
|
|
|
+ }
|
|
|
+ //下载之后删除
|
|
|
+ try {
|
|
|
+ if(descFile.exists()){
|
|
|
+ descFile.delete();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|