So I've been trying to read the html code from kickass.to(it works fine on other sites) but all I get is some weird gibberish. My code:
BufferedReader in = new BufferedReader(
new InputStreamReader(new URL("http://kickass.to/").openStream()));
String s = "";
while ((s=in.readLine())!=null) System.out.println(s);
in.close();
For example: Does anyone knows why it does that? thanks!
The problem here is a server that is probably not configured correctly, as it returns its response gzip compressed, even if the client does not send an
Accept-Encoding: gzip
header.So what you're seeing is the compressed version of the page. To decompress it, pass it through a GZIPInputStream: