public void returnWord(File file,String uuid,HttpServletResponse response) throws IOException{
response.reset();
response.setContentType("application/msword;charset=GBK");
response.setHeader("Content-Disposition", (new StringBuilder(
"attachment; filename=")).append(uuid).toString());
FileInputStream fis = new FileInputStream(file);
BufferedInputStream buff = new BufferedInputStream(fis);
response.setContentLength((int) file.length());
byte[] b = new byte[1024];// 相当于我们的缓存
long k = 0;
OutputStream myout = response.getOutputStream();
while (k < file.length()) {
int j = buff.read(b, 0, 1024);
k += j;
myout.write(b, 0, j);
}
myout.flush();
if (buff != null) {
buff.close();
file.deleteOnExit();
}
}
response.reset();
response.setContentType("application/msword;charset=GBK");
response.setHeader("Content-Disposition", (new StringBuilder(
"attachment; filename=")).append(uuid).toString());
FileInputStream fis = new FileInputStream(file);
BufferedInputStream buff = new BufferedInputStream(fis);
response.setContentLength((int) file.length());
byte[] b = new byte[1024];// 相当于我们的缓存
long k = 0;
OutputStream myout = response.getOutputStream();
while (k < file.length()) {
int j = buff.read(b, 0, 1024);
k += j;
myout.write(b, 0, j);
}
myout.flush();
if (buff != null) {
buff.close();
file.deleteOnExit();
}
}