title: java.net.SocketException Permission denied
body: <p>Hi everyone I am trying to read the content of a website with the following code</p>
  
  <pre><code>public class Add extends MenuActivity {
  
      Button submit;
      EditText editText;
      private WebView webView;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_add);
  
          String contents = urlToString("http://www.vogella.com");
  
          submit = (Button) findViewById(R.id.button1);
          editText = (EditText) findViewById(R.id.editText1);
  //        String addUrl = editText.getText().toString();
          submit.setOnClickListener(new OnClickListener()
          {
              public void onClick(View v)
              {
                  Log.d("Submit"," Pressed");
                  Log.d("EditText",editText.getText().toString());
              }
  
          });
  
      }
  
  
      private String urlToString(String address) {
          HttpURLConnection con = null;
          URL url;
          InputStream is = null;
          try {
              url = new URL(address);
              con = (HttpURLConnection) url.openConnection();
              con.setReadTimeout(10000);
              con.setConnectTimeout(15000);
              con.setRequestMethod("GET");
              con.connect();
              is = con.getInputStream();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          BufferedReader reader = null;
          StringBuilder sb = new StringBuilder();
          try {
              reader = new BufferedReader(new InputStreamReader(is));
              String line = "";
              while ((line = reader.readLine()) != null) {
                  sb.append(line);
                  Log.d("HTTP", line);
              }
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              if (reader != null) {
                  try {
                      reader.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              if (is != null) {
                  try {
                      is.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
          return sb.toString();
      }
  
  
  }
  </code></pre>
  
  <p>But I get the following error and I don't know how to solve it.</p>
  
  <pre><code>01-09 14:27:54.405: W/System.err(637): java.net.SocketException: Permission denied
  01-09 14:27:54.416: W/System.err(637):  at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocketImpl(Native Method)
  01-09 14:27:54.416: W/System.err(637):  at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocket(OSNetworkSystem.java:186)
  01-09 14:27:54.416: W/System.err(637):  at org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:265)
  01-09 14:27:54.416: W/System.err(637):  at java.net.Socket.checkClosedAndCreate(Socket.java:873)
  01-09 14:27:54.461: W/System.err(637):  at java.net.Socket.connect(Socket.java:1020)
  01-09 14:27:54.461: W/System.err(637):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.&lt;init&gt;(HttpConnection.java:62)
  01-09 14:27:54.461: W/System.err(637):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
  01-09 14:27:54.461: W/System.err(637):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
  01-09 14:27:54.461: W/System.err(637):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:909)
  01-09 14:27:54.466: W/System.err(637):  at uk.ac.tees.L1087591.Add.urlToString(Add.java:74)
  01-09 14:27:54.466: W/System.err(637):  at uk.ac.tees.L1087591.Add.onCreate(Add.java:33)
  01-09 14:27:54.466: W/System.err(637):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  01-09 14:27:54.466: W/System.err(637):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  01-09 14:27:54.466: W/System.err(637):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  01-09 14:27:54.466: W/System.err(637):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  01-09 14:27:54.466: W/System.err(637):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  01-09 14:27:54.466: W/System.err(637):  at android.os.Handler.dispatchMessage(Handler.java:99)
  01-09 14:27:54.466: W/System.err(637):  at android.os.Looper.loop(Looper.java:123)
  01-09 14:27:54.466: W/System.err(637):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  01-09 14:27:54.466: W/System.err(637):  at java.lang.reflect.Method.invokeNative(Native Method)
  01-09 14:27:54.466: W/System.err(637):  at java.lang.reflect.Method.invoke(Method.java:521)
  01-09 14:27:54.476: W/System.err(637):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  01-09 14:27:54.476: W/System.err(637):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  01-09 14:27:54.476: W/System.err(637):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>If you have any ideas don't be shy.</p>