下载文件代码
麻烦看下下面这段代码为什么不能实现下载文件的功能?
if(null != file){
byte [] buffer = new byte [1024]; // 缓冲区
OutputStream output = null ;
InputStream input = null ;
try{
response.setContentType("application/text/plain");
response.setHeader("Content-Disposition", "attachment; filename="+checkFileFileName);
output = response.getOutputStream();
input = new BufferedInputStream(new FileInputStream(file));
int i = -1;
while ((i = input.read(buffer)) != -1) {
output.write(buffer, 0, i);
}
output.flush();
} catch(Exception e) {
e.printStackTrace();
}
finally {
try{
if(input != null ) input.close();
if(output != null ) output.close();
} catch(
IOException ioe) {
ioe.printStackTrace();
}
}
}
点击链接后进入这个方法正常执行完毕之后没有反应··