/**
* 公共 download
* @param response
* @param path
* @param name
* @throws Exception
*/
private void download(HttpServletResponse response, String path, String name)
throws Exception {
response.setContentType("application/xls;charset=UTF-8");
response.setHeader("Content-disposition", "attachment;filename="
+ toUTF8(name));
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
FileInputStream fis = new FileInputStream(path);
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(response.getOutputStream());
byte buff[] = new byte[2048 * 10];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null) {
bis.close();
bis = null;
}
if (bos != null) {
bos.close();
bos = null;
}
new File(path).delete();
}
}