首页 > 代码库 > 调用浏览器下载

调用浏览器下载

//设置Content-Disposition
response.setHeader("Content-Disposition", "attachment;filename="+docName);

//读取文件
InputStream in = new FileInputStream(fullFileName);
OutputStream outs = response.getOutputStream();

//写文件
int b;
while((b=in.read())!= -1)
{
outs.write(b);
}

in.close();
outs.close();

调用浏览器下载