下载文件的代码,不论格式,从碰盘将文件读出来,下载
response.setContentType("application/x-download");//设置为下载application/x-download
response.addHeader("Content-Disposition","attachment;filename=" + filePath);
OutputStream outputStream = response.getOutputStream();
String fileRealPath = "";
fileRealPath = siteRealPath + filePath;
InputStream inputStream = new FileInputStream(fileRealPath);
byte[] buffer = new byte[1024];
int i = -1;
while ((i = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, i);
}
outputStream.flush();
outputStream.close();
2008年7月23日星期三
订阅:
博文评论 (Atom)
没有评论:
发表评论