GZipTest
来源:互联网 发布:库管软件免费版 编辑:程序博客网 时间:2024/06/18 08:08
package com.helloweenvsfei.test;import java.net.URL;import java.net.URLConnection;import java.text.NumberFormat;public class GZipTest {public static void test(String url) throws Exception {/** 支持 GZIP 的连接 */URLConnection connGzip = new URL(url).openConnection();connGzip.setRequestProperty("Accept-Encoding", "gzip");int lengthGzip = connGzip.getContentLength();/** 不支持 GZIP 的连接 */URLConnection connCommon = new URL(url).openConnection();int lengthCommon = connCommon.getContentLength();double rate = new Double(lengthGzip) / lengthCommon;System.out.println("网址: " + url);System.out.println("压缩后: " + lengthGzip + " byte, \t压缩前: "+ lengthCommon + " byte, \t比率: "+ NumberFormat.getPercentInstance().format(rate));System.out.println();}public static void main(String[] args) throws Exception {test("http://localhost:8080/filter/dojo/dojo.js");test("http://localhost:8080/filter/image.jsp");test("http://localhost:8080/filter/winter.jpg");}}
0 0
- GZipTest
- Excel中的数据导入到SqlServer数据库中
- iOS-开发技巧-三种收起键盘的方法
- Android学习笔记(一)
- Android 显式启动 其他应用的服务失败原因
- 踢足球
- GZipTest
- 360在线笔试---反思两道题
- HDOJ 5373 The shortest problem 水
- Codeforces 7E
- 图结构练习——判断给定图是否存在合法拓扑序列
- java设计模式之观察者模式
- Hexagon的程序执行顺序(一)
- VMWare虚拟机下为Ubuntu 配置静态IP(NAT方式)
- 浅谈C++中类的const成员变量,static成员变量和const static成员变量的区别