String pathend = this.getRequest().getParameter("path");
// path:\\172.16.11.101\cic\CICRecPRO\201203\0901\00\Call_2001287506_2001287509.wav
try {
pathend=java.net.URLDecoder.decode(pathend,"UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
OutputStream os = null;
InputStream fis = null;
byte[] temp = null;
try {
getResponse().reset();
getResponse().setContentType("application/x-msdownload");
getResponse().setHeader("Content-Disposition",
"attachment;filename=" + pathend);
File file = new File(pathend);
if (file.exists() == false){
return NONE;
}
fis = new FileInputStream(file);
os = this.getResponse().getOutputStream();
temp = new byte[fis.available()];
int i = 0;
while ((i = fis.read(temp)) != -1) {
os.write(temp, 0, i);
}
os.flush();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
if(os != null){
os.close();
}
if(fis != null){
fis.close();
}
if(temp != null){
temp = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return NONE;
}
弹出IE下载框提供下载的方法
最新推荐文章于 2021-03-02 15:40:19 发布