title: not able to understand getInputStream() of URLConnection
body: <p>Below is the code of getInputStream() defined in URLConnection</p>
  
  <pre><code>public InputStream getInputStream() throws IOException {
          throw new UnknownServiceException("Does not support writing to the input stream");
      }
  </code></pre>
  
  <p>I'm using this to get an inputstream object in my code</p>
  
  <pre><code>private String makeHttpRequest(URL url) throws IOException {
              String jsonResponse = "";
              HttpURLConnection urlConnection = null;
              InputStream inputStream = null;
              try {
                  urlConnection = (HttpURLConnection) url.openConnection();
                  urlConnection.setRequestMethod("GET");
                  urlConnection.setReadTimeout(10000 /* milliseconds */);
                  urlConnection.setConnectTimeout(15000 /* milliseconds */);
                  urlConnection.connect();
                  inputStream = urlConnection.getInputStream();
                  jsonResponse = readFromStream(inputStream);
              } catch (IOException e) {
                  // TODO: Handle the exception
              } finally {
                  if (urlConnection != null) {
                      urlConnection.disconnect();
                  }
                  if (inputStream != null) {
                      // function must handle java.io.IOException here
                      inputStream.close();
                  }
              }
              return jsonResponse;
          }
  </code></pre>
  
  <blockquote>
    <p>inputStream = urlConnection.getInputStream();</p>
  </blockquote>
  
  <p>How does this statement work because in its definition it is throwing a UnknownServiceException()</p>