if(StringUtils.isNoneBlank(tplUrl)){
InputStream in = null ;
OutputStream out = null;
try {
String suffix = tplUrl.substring(tplUrl.lastIndexOf(".") + 1);
out = response.getOutputStream();
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="+new String(fileName.getBytes(),"iso-8859-1")+"."+suffix);
String orgTplUrl = fileRep.getFileUploadPath() + tplUrl;
URL url = new URL(orgTplUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(3000);
conn.setRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
in = conn.getInputStream();
int b;
while((b=in.read())!= -1){
out.write(b);
}
falg = true;
} catch (Exception e) {
e.printStackTrace();
} finally{
if(in != null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(out != null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
最后
以上就是缓慢睫毛最近收集整理的关于下载文件的全部内容,更多相关下载文件内容请搜索靠谱客的其他文章。
发表评论 取消回复