我请求发送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(不发送该标题,我的代码运行良好)