title: Get error in HTTP Url Connection
body: <p>I'm working on an Application for my School, and I want to show the news from the Website, so I have to get the Sourcecode in my Application. This is my Code for getting the Html- Sourcecode from the Website:</p>
  
  <pre><code>public String getHTML(String urlToRead) {
      URL url;
      HttpURLConnection conn;
      BufferedReader rd;
      String line;
      String result = "";
      try {
          url = new URL(urlToRead);
          conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
          while ((line = rd.readLine()) != null) {
              result += line;
          }
          rd.close();
      } catch (Exception e) {
          result += e.toString();
      }
      return result;
  }
  </code></pre>
  
  <p>If I have an Internet connection, it works fine, but if there's no connection, the App crashes. How can I show an Error in the App, if there's no connection to the Internet, without crashing it?
  (Sorry for my English, I'm a pupil from Germany...)</p>
  
  <p>Can anyone help me?</p>
  
  <p>Thanks</p>
  
  <p>Jonathan</p>