Java HttpConnection/HttpsConnection input/error stream
<p>In java how do you know whether you have an error stream from a Http(s)connection or if it is an InputStream? The only way I can tell to do it is go for both, check for null and catch any exceptions. </p>

<pre><code>    HttpConnection con = (HttpConnection)URL.openConnection();
    //Write to output
    InputStream in = con.GetInputStream();
    //Vs
    InputStream error = con.getErrorStream();
</code></pre>

<p>How does java determine which stream it has? Is it based solely on response code of the connetion? So if its >=200 and &lt;300 then its inputStream otherwhise its an errorStream?</p>

<p>Thanks.</p>
