Using UrlConnection Openstream mutiple times in a loop
<p>I have a application on android where I want to read data from a url on the 3g and wifi interface of my phone. I am using the following code</p>

<pre><code>read_data() {
  url = new URL("http://0xbadc0ffee.de/plHUGE.txt");
  UrlConnection conn = url.openConnection;
  reader = new BufferedInputStream(conn.getInputStream());
  //Then I write this into a FileOutput stream
  reader.close();
}
</code></pre>

<p>This works fine when I run it twice on the 3g and wifi interface. But when I put this in a loop it fails to get the Inputstream. Initially I doubted if the stream was getting closed properly or not, but if it wasnt how would it work the first 2 times on the 2 interfaces? I have been stuck with this for over 2 days now... Any pointers are appreciated..</p>
