<%
response.setContentType(fileminitype);
response.setHeader("Location",filename);
response.setHeader("Cache-Control", "max-age=" + cacheTime);
//filename应该是编码后的(utf-8)
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
response.setContentLength(filelength);
OutputStream outputStream = response.getOutputStream();
InputStream inputStream = new FileInputStream(filepath);
byte[] buffer = new byte[1024];
int i = -1;
while ((i = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, i);
}
outputStream.flush();
outputStream.close();
inputStream.close();
outputStream = null;
%>
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType(" text/plain ");
OutputStream outputStream = null;
try {
outputStream = res.getOutputStream();
//把文件路径为srcFile的文件写入outputStream中
popFile(srcFile, outputStream)) ;
} catch (IOException e) {
e.printStackTrace();
}
}
URLConnection con;
try {
//url是被调用的SERVLET的网址 如 *.do
con = url.openConnection();
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestProperty("Content-Type",
"application/octet-stream");
InputStream in = con.getInputStream();
ProgressMonitorInputStream pmInputStream = new ProgressMonitorInputStream
(pane, "正在从服务器下载文件内容", in);
ProgressMonitor pMonitor = pmInputStream.getProgressMonitor();
pMonitor.setMillisToDecideToPopup(3);
pMonitor.setMillisToPopup(3);
//localfilepath本地路径,localstr文件文件夹,filename本地文件名
String localfilepath = localstr + filename ;
//方法saveFilsaveFilee是把输入流pmInputStream写到文件localfilepath中
if(saveFilsaveFilee(localfilepath,pmInputStream)){
openLocalFile(localfilepath);
}
URLConnection con;
try {
con = url.openConnection();
//url是被调用的SERVLET的网址 如 *.do
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestProperty("Content-Type","application/octet-stream");
OutputStream out = con.getOutputStream();
//localfilepath本地路径,localstr文件文件夹,filename本地文件名
String localfilepath = localstr + filename;
//文件getOutputStream是把文件localfilepath写到输出流out中
getOutputStream(localfilepath,out);
InputStream in = con.getInputStream();
return true;
}catch (IOException e) {
System.out.println("文件上传出错!");
e.printStackTrace();
}
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType(" text/plain ");
InputStream inputStream = null;
try {
inputStream = res.getInputStream();
//把输入流inputStream保存到文件路径为srcFile的文件中
writefile(srcFile, inputStream);
} catch (IOException e) {
e.printStackTrace();
}
} // end service
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有