title: Not Reading text from server
body: <p>I am trying to read all the text from server, I think that my code is not retrieving text from server will you please help me how can I fix this problem, I am new to android development. Thanks in advance</p>
  
  <pre><code>public class TestActivity extends Activity {
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      TextView tv= (TextView)findViewById(R.id.my_text);
  
  
                  try {
  
                      URL url = new URL("http://www.google.com:80/");
                      StringBuilder content = new StringBuilder();
                      // read text returned by server
  
                      BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                      String line;
                      while ((line = in.readLine()) != null) {
                          content.append(line +"\n");
                      }
                      tv.setText(content.toString());
                      setContentView(tv);
  
                      in.close();
                  }
  
                  catch (MalformedURLException e) {
  
                      System.out.println("Malformed URL: " + e.getMessage());
  
                  }
  
                  catch (IOException e) {
  
                      System.out.println("I/O Error: " + e.getMessage());
  
                  }
  
  
  };        
  
  
  }
  </code></pre>