title: Howto handle connection timeout errors for URLConnection (Java, Android)
body: <p>I have the following code:</p>
  <pre><code>        try {
              url = new URL(sURL);
              URLConnection connection  = url.openConnection();
              connection.setConnectTimeout(1000);
              connection.setReadTimeout(2000);
              InputStream inputStream = connection.getInputStream();
              BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, &quot;UTF-8&quot;));
  </code></pre>
  <p>&lt;Read from reader ...&gt;
  catch (IOException e) {
  e.printStackTrace();
  }</p>
  <p>How can I detect connection-timeout issue? I would like to handle this event as a special case.
  IOException is to general for my purpose.</p>
  <p>Any help?</p>