title: how to get data from url in android studio
body: <p>I want to get data from url and show in a textView , But after receiving, it only shows html codes.</p>
  
  <p>I use a Educational video but my result is wrong.</p>
  
  <p>I used another methods too but all result are same and just show html codes.</p>
  
  <p><strong>MainActivity :</strong></p>
  
  <pre><code>public static final String SAMPLE_URL = "http://nimatest.epizy.com/ffff.json";
  
  findViewById(R.id.btn_get_data).setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             new TaskGetData().execute(SAMPLE_URL);
         }
     });
  
  public class TaskGetData extends AsyncTask&lt;String , String , String&gt;{
  
  @Override
  protected void onPreExecute() {
      textView.append("Get data ...\n\n");
  }
  
  @Override
  protected String doInBackground(String... params) {
      return MyHttpUtils.getDataHttpUriConnection(params[0]);
  }
  
  @Override
  protected void onPostExecute(String result) {
      textView.append(result + "\n");
      }
  }
  </code></pre>
  
  <p><strong>MyHttpUtils :</strong></p>
  
  <pre><code>public static String getDataHttpUriConnection(String uri){
      try {
          URL url = new URL(uri);
          HttpURLConnection con = (HttpURLConnection) url.openConnection();
          String result = inputStreamToString(con.getInputStream());
          return result;
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      return null;
  }
  
  public static String inputStreamToString(InputStream stream)  {
      BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
      StringBuilder sb = new StringBuilder();
      String line = "";
      try
      {
          while ((line = reader.readLine()) != null)
          {
              sb.append(line);
              sb.append("\n");
          }
          return sb.toString();
      }
      catch (IOException e)
      {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p><img src="https://img.techpowerup.org/190609/probpic.jpg" alt="a busy cat"></p>