title: Android - How can I read a text file from a url?
body: <p>I uploaded a text file(*.txt) to a server, now I want to read the text file...</p>
  
  <p>I tried this example without luck.</p>
  
  <pre><code>ArrayList&lt;String&gt; urls=new ArrayList&lt;String&gt;(); //to read each line
  TextView t; //to show the result
  try {
          // Create a URL for the desired page
          URL url = new URL("mydomainname.de/test.txt"); //My text file location
          // Read all the text returned by the server
           BufferedReader in = new BufferedReader(new     InputStreamReader(url.openStream()));
  
      t=(TextView)findViewById(R.id.TextView1);
      String str;
      while ((str = in.readLine()) != null) {
          urls.add(str);
  
  
      }
      in.close();
     } catch (MalformedURLException e) {
    } catch (IOException e) {
   }
   t.setText(urls.get(0)); // My TextFile has 3 lines 
  </code></pre>
  
  <p>App is closing itself...
  Can it be up to the domain name ? Should there be a IP instead ?
  I figured out that the while loop isn't executed.
  Because if I put t.setText* in the while loop there is no error, and the TextView is empty.
  LogCat Error : <a href="http://textuploader.com/5iijr" rel="noreferrer">http://textuploader.com/5iijr</a> it highlight the line with <code>t.setText(urls.get(0));</code></p>
  
  <p>Thanks in Advance !!!</p>