title: AsyncTask fails after end of loop
body: <p>I want to get the content of a web directory using a php script, stored on the web server.
  This PHP Script I execute in an AsyncTask, here's the code:</p>
  
  <pre><code>protected ArrayList&lt;String&gt; doInBackground(String... urls) {
          ArrayList&lt;String&gt; array = new ArrayList&lt;String&gt;();
          try {
              URL url = new URL("http:/www.example.org/folder/script.php");
              BufferedReader br = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
  
              String line = null;
  
              while((line = br.readLine()) != null){
                  array.add(line);
  
              }
              return array;
  
          } catch (MalformedURLException e){
              Log.e("error", e.getMessage());
              return null;
          } catch (IOException e){
              Log.e("error", e.getMessage());
              return null;
          }
      }
  </code></pre>
  
  <p>However, when the loop condition is fullfilled (line has the value "null") it instantly goes in the catch, but I don't even receive an exception.</p>
  
  <p>I've also tried it with a for loop, same result.</p>
  
  <pre><code>String line = br.readLine();
  
  for (; line != null ; ){
      array.add(line);
      line = br.readLine();
  
  }
  return array;
  </code></pre>
  
  <p>Any suggestions?</p>