采用URL访问资源,隐藏真实地址
2015-03-28 13:17
295 查看
public void test() throws IOException{ DataInputStream in=null; DataOutputStream temps=null; HttpServletResponse response = ServletActionContext.getResponse(); try{ // out.clear(); // out = pageContext.pushBody(); // 读到流中 //String strPdfPath = new String("/test/auto_pdf/files/"+gid+"/"+file_name); String downFileUrl="http://203.86.108.1/summary_traffic_report_web_test/summary_monthly_traffic_report_images_and_html_test/20499/all_sites_traffic_summary_201502.html"; URL downUrl = new URL(downFileUrl); URLConnection conn = downUrl.openConnection(); System.out.println(conn.getContent()); int dataSize = conn.getContentLength(); //取得要下载的数据的长度 System.out.print("dataSize = " + dataSize); // 设置输出的格式 response.reset(); response.setContentType("text/html"); // 如果是图片 则写成 response.setContentType("image/jpeg") temps = new DataOutputStream(response.getOutputStream()); in = new DataInputStream(conn.getInputStream()); byte[] b = new byte[2048]; int i = 0; while ((i = in.read(b)) > 0) { temps.write(b,0,i); temps.flush(); } }catch(Exception e){ e.printStackTrace(); }finally{ if(in!=null)in.close(); if(temps!=null)temps.close(); } }
相关文章推荐
- 防止其他URL地址直接访问本站资源【防盗链过滤器】
- 使用HttpURLConnection访问URL地址
- UrlRewritingNet 实现URL重写 映射 真实的.html(例如FCKeditor)无法访问的解决方法 .
- UrlRewritingNet 实现URL重写 映射 真实的.html(例如FCKeditor)无法访问的解决方法
- 使用HttpURLConnection访问HTTP资源
- Java 网络编程(三) 创建和使用URL访问网络上的资源
- 用户的访问权限过滤器,防止用户直接输入URL直接访问资源。
- 获取当前url地址和目录不包含访问的文件名
- 用php隐藏图片的真实地址
- SVN如何将版本库url访问地址中的https改为http
- SVN--清楚之前访问的svn里的url地址的方法
- 线程URL访问网络资源
- c#动态改变webservice的url访问地址
- thinkphp支持大小写url地址访问,不产生下划线
- Android上Java网络资源访问(二)使用HttpURLConnection多线程下载
- 让ThinkPHP支持大小写url地址访问的方法
- Nginx服务器下ThinkPHP5访问出现404以及URL隐藏index.php
- thinkPHP网络地址栏分隔符,url从写 隐藏index.php目录入口文件
- 【转】命令行浏览器 curl 命令详解,Linux中访问url地址