title: Android get web page source
body: <p>I want to get the source code of a web page that the users enters. When he presses the button, he should see the source in a <code>TextView</code>. This is my code:</p>
  
  <pre><code>final Button b = (Button) findViewById(R.id.button1);
  
          b.setOnClickListener(new OnClickListener() {
  
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  try {
                      URL url = null;
                      url = new URL(myEditText.getText().toString());
                      URLConnection conn = url.openConnection();
                      BufferedReader reader = new BufferedReader(
                              new InputStreamReader(conn.getInputStream()));
                      String line = "";
                      while ((line = reader.readLine()) != null) {
                          myTextView.append(line);
  
                      }
  
                  } catch (Exception e) {
  
                      Log.e("ERR",e.getMessage());
                  }
  
              }
          });
  </code></pre>
  
  <p>When I run it I get a NullPointerException at </p>
  
  <pre><code>BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
  </code></pre>
  
  <p>.-->Println needs a message.</p>
  
  <p>I don't know what is wrong, since this is from a video tutorial. I have written <code>&lt;uses-permission android:name="android.permission.INTERNET"/&gt;</code> in Manifest so, everything should be allright.</p>