title: Android with Kotlin - How to use HttpUrlConnection
body: <p>I´m trying to get data from a url inside an <code>AsyncTask</code> but I get an error when creating a new instance of <code>HttpUrlConnection</code>.</p>
  
  <p>Something like this on Java</p>
  
  <pre><code>URL url = new URL("http://www.android.com/");
  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  try {
      InputStream in = new BufferedInputStream(urlConnection.getInputStream());
      readStream(in);
  finally {
      urlConnection.disconnect();
  }
  </code></pre>
  
  <p>But I keep getting the error shown below.</p>
  
  <pre><code>class GetWeatherTask : AsyncTast&lt;Void, Void, Void&gt;() {
  
      override fun doInBackground(vararg params: Void?): Void? {
          val httpClient = HttpURLConnection();
          return null
      }
      override fun onPreExecute() {
          super.onPreExecute()
      }
      override fun onPostExecute(result: Void?) {
          super.onPostExecute(result)
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Cannot access '': it is 'protected/<em>protected and package</em>/' in 'HttpURLConnection' Cannot create an instance of an abstract class</p>
  </blockquote>
  
  <p>Am I missing something? I tryied to create a class object extending <code>HttpUrlConnection</code> and try to implement the <code>init</code> method but I couldn't</p>
  
  <p>Thanks in advance.</p>