title: Cannot resolve method openConnection()
body: <p>I'm trying to download web content from a URL using the code below:</p>
  
  <pre><code>URL content = new URL(urlstr);
      HttpURLConnection urlConnection = (HttpURLConnection) content.openConnection();
  
      try {
          InputStream in = urlConnection.getInputStream();
          InputStreamReader isw = new InputStreamReader(in);
  
          String existing_string = "";
          StringBuilder builder = new StringBuilder(existing_string);
          int data = isw.read();
          while (data != -1) {
              char current = (char) data;
              builder.append(current);
              data = isw.read();
          }
  </code></pre>
  
  <p>The error I get is <code>Cannot resolve method openConnection()</code>. Import statements look like this:</p>
  
  <pre><code>import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  </code></pre>
  
  <p>I have look at <em>ALMOST</em> all SO related questions on this, but I dont seem to get it working.</p>