title: Android read text file from internet
body: <p>I want to read a remote text file and show its content in a textview. I have written this below code, but it doesn't get any information from the text file. 
  How can I find the reason of this problem or solve it?
  isn't there anything wrong in my code?</p>
  
  <pre><code>    private void readFile()
      {
           try {
              String path ="http://host.com/info.txt";
              URL u = new URL(path);
              HttpURLConnection c = (HttpURLConnection) u.openConnection();
              c.setRequestMethod("GET");
              c.setDoOutput(true);
              c.connect();
              InputStream in = c.getInputStream();
              Log.e("value",in.toString());
              AssetManager mngr=getAssets();
              ByteArrayOutputStream bo = new ByteArrayOutputStream();
              byte[] buffer = new byte[1024];
              in.read(buffer); // Read from Buffer.
              bo.write(buffer); // Write Into Buffer.
              TextView text = (TextView) findViewById(R.id.TextView1);
              text.setText(bo.toString());
              bo.close();
              }
           catch (NetworkOnMainThreadException e) {
          }
              catch (MalformedURLException e) {
              e.printStackTrace();
              } catch (FileNotFoundException e) {
              e.printStackTrace();
              } catch (IOException e) {
              e.printStackTrace();
              }
      }
  }
  </code></pre>