title: Download a text file from the web - Android/ Java
body: <p>I'm trying to get save a text file from the internet into a folder in my res directory (res/files) so I can then read and interpret it. My android manifest has set the appropiate permissions but when I test it in the simulator it fails. </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"&gt;&lt;/uses-permission&gt;
  </code></pre>
  
  <p>Here's the method to get the file:  </p>
  
  <pre><code>public void getTextFile(){
      String path ="http://hullmc.org.uk/cjvize/test.txt";
      URL u = null;
      try {
          u = new URL(path);
          BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
          int i = 0;
          String replicated = "";
          do{
              String str = in.readLine();
              replicated = replicated + "/n" + str;
              i++;
          }while(i&lt;85);
          in.close();
      }
      catch(Exception e){
          welcome.setText("Failed");
      }
  }
  </code></pre>
  
  <p>Can anyone suggest why this is not working? Many thanks!</p>