如何gzip压缩html文件怎么打开,如何使用Content-Encoding读取压缩的HTML页面:gzip

我请求发送Content-Encoding:gzip标头的网页,但却被卡住了怎么读..

我的代码:

try {

URLConnection connection = new URL("http://jquery.org").openConnection();

String html = "";

BufferedReader in = null;

connection.setReadTimeout(10000);

in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

String inputLine;

while ((inputLine = in.readLine()) != null){

html+=inputLine+"\n";

}

in.close();

System.out.println(html);

System.exit(0);

} catch (IOException ex) {

Logger.getLogger(Crawler.class.getName()).log(Level.SEVERE, null, ex);

}

输出看起来非常混乱..(我无法将其粘贴到这里,某种符号......)

我相信这是一个压缩内容,如何解析呢?

注意:

如果我将jquery.org更改为jquery.com(不发送该标题,我的代码运行良好)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值