/**
*
* @Title: downloadExcelTemplate
* @Description:下载指定路径文件
* @param response
* @param request
* @param templeteName
* @throws IOException
*
*/
public void downloadExcelTemplate(HttpServletResponse response, String templeteName)
throws IOException {
// TODO Auto-generated method stub
OutputStream outp = null;
FileInputStream in = null;
try {
// 要下载的模板所在的绝对路径
response.reset();
response.addHeader("Content-Disposition", "attachment; filename=" + templeteName);
response.setContentType("application/octet-stream;charset=UTF-8");
outp = response.getOutputStream();
in = new FileInputStream(templeteName);
byte[] b = new byte[1024];
int i = 0;
while ((i = in.read(b)) > 0) {
outp.write(b, 0, i);
}
outp.flush();
} catch (Exception e) {
System.out.println("Error!");
e.printStackTrace();
} finally {
if (in != null) {
in.close();
in = null;
}
if (outp != null) {
outp.close();
outp = null;
}
}
}