2

I am trying to get response from a website. I am using HttpURLConnection class.

this is my code:

        BufferedReader in = null;  
  in = new BufferedReader(new InputStreamReader(httpCon.getInputStream()));  
  String Line;

  while ((Line= in.readLine()) != null) {
    System.out.println(Line);
   }

All I get is :"�Q�u����0�_������q�J��R衔�J1�4q�Ȓ��d�%�ޑl/��^�0�ϯ�7�[6@~Ȟ�K��S��+u"

How can I decode it? Thank you.

Barak
  • 97
  • 1
  • 6

1 Answers1

2

The request is most likely GZipped. Use a GZIPInputStream to read the request.

  BufferedReader in = null;  
  in = new BufferedReader(new InputStreamReader(new GZIPInputStream(httpCon.getInputStream())));  
  String Line;

  while ((Line= in.readLine()) != null) {
    System.out.println(Line);
   }
Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189
  • Thank you! it was GZIPInputStream ! – Barak May 17 '13 at 12:50
  • @user2126373 Excellent! I had this same issue a few months back, I was glad I could pass this one on. If that solved your issue could you please accept? I'm one vote away from 20k!!!!! – Kevin Bowersox May 17 '13 at 12:53