title: Reading source code from a webpage in java
body: <p>I am trying to read source code from a webpage. My java code is</p>
  
  <pre><code>import java.net.*;
  import java.io.*;
  import java.util.*;
  import javax.swing.JOptionPane;
  
  class Testing{
  public static void Connect() throws Exception{
  
  
    URL url = new URL("http://excite.com/education");
    URLConnection spoof = url.openConnection();
  
  
    spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
    BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
    String strLine = "";
  
  
    while ((strLine = in.readLine()) != null){
  
  
     System.out.println(strLine);
    }
  
    System.out.println("End of page.");
   }
  
   public static void main(String[] args){
  
    try{
  
     Connect();
    }catch(Exception e){
  
    }
  }
  </code></pre>
  
  <p>When i compile and run this code, it gives the following output:</p>
  
  <p>�<code>I�%&amp;/m�{J�J��t�</code>$ؐ@������iG#)�*��eVe]f@�흼��{���{���;�N'���?\fdl��J�ɞ!���?~|?"~�$}�>�������4�����7N�����+�ӲM�N��?J�tZfM��G�j����R��!�9�?>JgE��Ge[����ⳏ���W�?�����8������
  �|8�
  ���������ho����0׳���|փ:--�|�L�Uο�׫��m�zt�n3��l\�w��O^f�G[�CG&lt;�y6K��gM�rg��ǟy�Eִy����h˜��ؗ˲X���l=�ڢZ�/����(կ^O�UU6�����&amp;�6_�<code>@yC}�p�y���lAH�ͯ��zF#�V�6_��}��)�v=J+�$��̤�G�Y�L�b���wS"�7�y^����Z�m���Y:ɛ���J&lt;N_�Y=���U�f���,���y�Q2(J٩P!ͨ�i����1&amp;F0&amp;ૼn�?�x�T��h�Qzw�+����n�)�h��K��2����8g����⮥��A0
  ���1I�%����Q�Z����{��������w���?x����N�?�&lt;d�S��۫�%a|4�j��z���k�Bak��k-�c�z�g��z���l</code>>���֎s^,��5��/B�{����]]����Ý�ֳ���y{�_l�8g�k�ӫ�b���"+|��(��M��^[���<code>J�P��_�..?������x�Z�$</code>������E>��느�u���E~����{媘���f�e1ͷ�QZ,�����f��e�3Jٻb�^��4��۴���><em>��y��;��&lt;렛{�l��ZfW
  S@  {�]��1��Q</em>�����n[<code>�,t�?����~�n�S�u#SL��n�^��������EC��q�/�y���FE�tpm������e&amp;��oB���z9eY��������P��IK?����̦����w�N��;�;J?����;�/��5���M���rZ��q��]��C�dᖣ��F�nd���}���A5���M�5�.�:��/�_D�?�3����'�c�Z7��}��(OI),ۏi����{�&lt;�w�������DZ?e����'q���eY]=���kj���߬������\qhrRn���l�o-��.���k��_���oD8��GA�P�r��|$��ȈPv~Y�:�[q?�sH�� &lt;��C��ˬ�^N�[ v(��S��l�c�C����3���E5&amp;5�VӪL�T��۔���oQrĈ��/���#[f�5�5"�</code>���[���t�vm�\��.0�nh����aڌWYM
  ^T�|\,��퓜�L�u����B�̌�C�r������ �������'�%�{��)�);�fV�]��g,�>�C  �c2���p�4��}H���P��(�%j"�}�&amp;�:�Oh\5I�l�氪��{�/�]�LB�l��2��I"��=��Y�|�>�֏n�������}�����~�[��'�<em>�O��
  ��:/�)�Wz�3��lo�.5�k�&amp;����H[ji�����b������WWy}�5�֝Q�|f�����]�KjH5��}yNm�����g</em>�ӷ�ǣ��>��'o��泏��&lt;���G�g���>->�xQM�����%&lt;�|����u�.��3���[�[r���ٝ;���]4E��6[����]����1���*�8}��n�w�������ݽ����|����}|qo|�~u����w|�i�i���Z�`z�ŧ����Q}�u��!���w   �O���R9�)�~��g~߻w6��{���wd�o��/Z�uUS��݄l��I^�����>��[�U1�o�_��J��}��@�@�U�/��/?���i�7|CZT?(�2b~����c�W�c5'����EeFĿꇙ�0��T��{��W�2����/���O���YJj����K/���>��:'_l�</p>
  
  <p>Other than URLs from this directory i.e. "excite.com/education" all URLs are giving correct source codes but these URLs are creating problems.</p>
  
  <p>Anyone Please Help.</p>
  
  <p>Thanks in advance.</p>