zhang6622056的专栏

Java虚拟机之堆分析

弹出IE下载框提供下载的方法

String pathend = this.getRequest().getParameter("path");
// path:\\172.16.11.101\cic\CICRecPRO\201203\0901\00\Call_2001287506_2001287509.wav
 try {
			pathend=java.net.URLDecoder.decode(pathend,"UTF-8");
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		OutputStream os = null;
		InputStream fis = null;
		byte[] temp = null;
		
		try {
			getResponse().reset();
			getResponse().setContentType("application/x-msdownload");
			getResponse().setHeader("Content-Disposition",
					"attachment;filename=" + pathend);
			File file = new File(pathend);
			if (file.exists() == false){
				return NONE;
			}
			fis = new FileInputStream(file);
			os = this.getResponse().getOutputStream();
			temp = new byte[fis.available()];
			int i = 0;
			while ((i = fis.read(temp)) != -1) {
				os.write(temp, 0, i);
			}
			os.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
				try {
					if(os != null){
						os.close();
					}
					if(fis != null){
						fis.close();
					}
					if(temp != null){
						temp = null;
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
		}
		return NONE;
	}
	


阅读更多
上一篇Ext.form.Combox静态下拉框的编写
下一篇Class文件夹为空,Tomcat发布不上去的原因解决
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭